如何在 NPM 版本中表示内部版本号? [英] How to represent build number in NPM version?

查看:70
本文介绍了如何在 NPM 版本中表示内部版本号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 package.json 中为我的项目附加一个内部版本号.我正在寻找最好的方法.

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

我发现 node-semver 将字符串识别为内部版本号,如果前面有 '+'.例如,这将是构建123".

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

然而,NPM 版本模块也将接受这种格式,但会删除 package.json 中的内部版本号.我应该如何在 package.json 中表示内部版本号?

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?

推荐答案

+ 确实是表示版本号的方式.但是从 npm semver 的角度来看,拥有相同版本的不同构建是没有意义的.所以去掉内部版本号是有一定意义的.

+ 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.

如果您正在执行不同的构建,因为这些是一系列预发布,请使用 - 而不是 +.npm version prerelease 会将 1.0.0 增加到 1.0.1-0.另一个 npm version prerelease 将增加到 1.0.1-1.

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.

这篇关于如何在 NPM 版本中表示内部版本号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆