程序go 2014-03-11 22:02 采纳率: 100%
浏览 428
已采纳

Package.json 中的 tilde (~)和 caret (^)有什么区别?

After I upgraded to 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. Why are these changes made in npm?
  2. What is the difference between tilde(~) and caret(^)?
  3. What is the advantages over others?

转载于:https://stackoverflow.com/questions/22343224/whats-the-difference-between-tilde-and-caret-in-package-json

  • 写回答

14条回答 默认 最新

  • 妄徒之命 2014-03-12 00:28
    关注

    In the simplest terms, the tilde matches the most recent minor version (the middle number). ~1.2.3 will match all 1.2.x versions but will miss 1.3.0.

    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.x.x release including 1.3.0, but will hold off on 2.0.0.

    http://fredkschott.com/post/2014/02/npm-no-longer-defaults-to-tildes/

    Note that the author's terminology is somewhat misleading: when he says "the most recent minor version" for ~ he means "the most recent patch version in the specified minor version". Similarly for ^, "the most recent major version" should be read as "the most recent minor version in the specified major version".

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(13条)
编辑
预览

报告相同问题?

悬赏问题

  • ¥15 matlab中频率调制法代码的解读
  • ¥15 ceph的对象、块、文件相关问题求解答
  • ¥50 如果使用python进行ERA5 10米风场预报检验
  • ¥15 navicat解析mysql密码
  • ¥15 SDAPI(关键词-table)
  • ¥15 unity安卓打包出现问题
  • ¥20 安装catkin时遇到了如下问题请问该如何解决呢
  • ¥15 VAE模型如何输出结果
  • ¥15 编译python程序为pyd文件报错:{"source code string cannot contain null bytes"
  • ¥20 关于#r语言#的问题:广义加行模型拟合曲线后如何求拐点
手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部