package.json 中的波浪号(~) 和插入符号(^) 有什么区别?
在升级到最新的稳定版node
和npm
后,我尝试了npm install moment --save
.它使用插入符号 ^
前缀将条目保存在 package.json
中.以前,它是波浪号 ~
前缀.
After I upgraded to the latest stable node
and npm
, I tried npm install moment --save
. It saves the entry in the package.json
with the caret ^
prefix. Previously, it was a tilde ~
prefix.
- 为什么要在
npm
中进行这些更改? - 波浪号
~
和插入符号^
有什么区别? - 与其他公司相比有哪些优势?
- Why are these changes made in
npm
? - What is the difference between tilde
~
and caret^
? - What are the advantages over others?
~version
大约相当于版本",将更新您到所有未来的补丁版本,而不会增加次要版本.~1.2.3
将使用从 1.2.3 到
~version
"Approximately equivalent to version", will update you to all future patch versions, without incrementing the minor version.~1.2.3
will use releases from 1.2.3 to <1.3.0.
^version
与版本兼容",会将您更新到所有未来的次要/补丁版本,而不会增加主要版本.^2.3.4
将使用从 2.3.4 到
^version
"Compatible with version", will update you to all future minor/patch versions, without incrementing the major version. ^2.3.4
will use releases from 2.3.4 to <3.0.0.
有关例外情况,请参阅下面的评论,特别是 对于pre-one版本,例如^0.2.3
See Comments below for exceptions, in particular for pre-one versions, such as ^0.2.3