package.json 中的波浪号(~) 和插入符号(^) 有什么区别? [英] What's the difference between tilde(~) and caret(^) in package.json?

查看:35
本文介绍了package.json 中的波浪号(~) 和插入符号(^) 有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在升级到最新的稳定版nodenpm 后,我尝试了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.

  1. 为什么要在 npm 中进行这些更改?
  2. 波浪号 ~ 和插入符号 ^ 有什么区别?
  3. 与其他公司相比有哪些优势?
  1. Why are these changes made in npm?
  2. What is the difference between tilde ~ and caret ^?
  3. What are the advantages over others?

推荐答案

请参阅 NPM 文档semver 文档:

  • ~version 大约相当于版本",将更新您到所有未来的补丁版本,而不会增加次要版本.~1.2.3 将使用从 1.2.3 到 <1.3.0 的版本.

  • ~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 到 <3.0.0 的版本.

^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

这篇关于package.json 中的波浪号(~) 和插入符号(^) 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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