How to represent build number in NPM version?

浪尽此生 提交于 2020-08-19 06:36:27

问题


I would like to attach a build number to my project in package.json. I'm looking for the best way to do so.

I've found that node-semver recognizes a string as a build number if preceded by '+'. For example this would be build '123'.

1.0.0+123

However, the NPM version module will also accept this format, but trims off the build number in package.json. How should I go about representing the build number in package.json?


回答1:


+ is indeed the way to represent build numbers. But having different builds of the same version does not make sense from an npm semver perspective. So stripping out the build number makes a certain amount of sense.

If you are doing different builds because these are a series of prereleases, use - instead of +. npm version prerelease will increment 1.0.0 to 1.0.1-0. Another npm version prerelease will increment to 1.0.1-1.



来源:https://stackoverflow.com/questions/29972999/how-to-represent-build-number-in-npm-version

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!