简体   繁体   English

npm是否尊重semver中较新的预发布版本?

[英]Does npm honour newer prerelease versions in semver?

In my app, I have users install dependencies by running npm install -- bog standard behaviour. 在我的应用程序中,我让用户通过运行npm install -bog标准行为来安装依赖项。

However, I have one package that changes frequently, and in an effort to not end up with a ridiculously large version number like 0.1.12324 , I stumbled upon the concept of pre-releases. 但是,我有一个经常更改的软件包,并且为了最终没有像0.1.12324这样可笑的大版本号,我偶然发现了预发布的概念。

How does npm treat prerelease numbers when running npm install ? 在运行npm install时, npm install如何处理预发布数字?

Assuming my package packageA has a version number of 0.1.1-r1234 , and my users have a dependency semver of ~0.1.1 : 假设我的包packageA的版本号为0.1.1-r1234 ,我的用户的依赖关系semver为~0.1.1

I know that a new user without packageA installed will automatically have that version ( 0.1.1-r1234 ) installed. 我知道没有安装packageA的新用户将自动安装该版本( 0.1.1-r1234 )。

What if someone already has packageA installed, of version 0.1.1-r1233 ? 如果某人已经安装了packageA ,版本为0.1.1-r1233怎么0.1.1-r1233 Does npm install know to install the newer pre-release? npm install是否知道安装较新的预发行版?

I seemed to have answered my own question. 我好像回答了自己的问题。 From the main page at semver.org : 从semver.org的主页面

Precedence for two pre-release versions with the same major, minor, and patch version MUST be determined by comparing each dot separated identifier from left to right until a difference is found as follows: identifiers consisting of only digits are compared numerically and identifiers with letters or hyphens are compared lexically in ASCII sort order. 具有相同主要版本,次要版本和补丁版本的两个预发行版本的优先级必须通过从左到右比较每个点分隔标识符来确定,直到找到差异如下:仅由数字组成的标识符在数字上与标识符与字母进行比较或者连字符以ASCII排序顺序进行词汇比较。 Numeric identifiers always have lower precedence than non-numeric identifiers. 数字标识符的优先级始终低于非数字标识符。 A larger set of pre-release fields has a higher precedence than a smaller set, if all of the preceding identifiers are equal. 如果所有前述标识符相等,则更大的预发布字段集合具有比较小集合更高的优先级。 Example: 1.0.0-alpha < 1.0.0-alpha.1 < 1.0.0-alpha.beta < 1.0.0-beta < 1.0.0-beta.2 < 1.0.0-beta.11 < 1.0.0-rc.1 < 1.0.0. 示例:1.0.0-alpha <1.0.0-alpha.1 <1.0.0-alpha.beta <1.0.0-beta <1.0.0-beta.2 <1.0.0-beta.11 <1.0.0- rc.1 <1.0.0。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM