简体   繁体   English

^在package.json依赖版本中

[英]^ in package.json dependency version

What does the ^ symbol mean in the version of a dependency in package.json? ^符号在package.json中的依赖版本中的含义是什么?

I couldn't find it in the docs . 我在文档中找不到它。

For example: 例如:

"dependencies": {
    "grunt": "^0.4.4",
    ...
}

I found an answer here : 我在这里找到答案:

The caret, on the other hand, is more relaxed. 另一方面,插入符号更放松。 It will update you to the most recent major version (the first number). 它会将您更新为最新的主要版本(第一个数字)。 ^1.2.3 will match any 1.xx release including 1.3.0 , but will hold off on 2.0.0 . ^1.2.3将匹配任何1.xx版本,包括1.3.0 ,但将在2.0.0推迟。 npm's semantic versioning parser clarifies the distinction: npm的语义版本解析器澄清了这种区别:

 ~1.2.3 := >=1.2.3-0 <1.3.0-0 "Reasonably close to 1.2.3". ^1.2.3 := >=1.2.3-0 <2.0.0-0 "Compatible with 1.2.3". 

― isaacs/node-semver (emphasis added) - isaacs / node-semver(强调添加)

The relevant points from isaacs/node-semver are: isaacs/node-semver的相关要点是:

  • ^1.2.3 := >=1.2.3-0 <2.0.0-0 Compatible with 1.2.3 . ^1.2.3 := >=1.2.3-0 <2.0.0-0 与1.2.3兼容
    When using caret operators, anything from the specified version (including prerelease) will be supported up to, but not including, the next major version (or its prereleases). 使用插入符号运算符时,将支持指定版本(包括预发行版)中的任何内容,但不包括下一个主要版本(或其预发行版)。 1.5.1 will satisfy ^1.2.3 , while 1.2.2 and 2.0.0-beta will not. 1.5.1将满足^1.2.3 ,而1.2.22.0.0-beta则不满足。

  • ^0.1.3 := >=0.1.3-0 <0.2.0-0 Compatible with 0.1.3 . ^0.1.3 := >=0.1.3-0 <0.2.0-0 与0.1.3兼容
    0.xx versions are special: the first non-zero component indicates potentially breaking changes, meaning the caret operator matches any version with the same first non-zero component starting at the specified version. 0.xx版本是特殊的:第一个非零组件表示可能发生重大更改,这意味着插入符操作符匹配从指定版本开始具有相同的第一个非零组件的任何版本。

  • ^0.0.2 := =0.0.2 Only the version 0.0.2 is considered compatible ^0.0.2 := =0.0.2 只有版本0.0.2被认为是兼容的

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

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