javascript - nodejs 的模块,版本号里的 ~ ^ * x是什么意思?
天蓬老师
天蓬老师 2017-04-11 11:52:32
[JavaScript讨论组]

例如:

{
  "name": "wdd",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "start": "node ./bin/www"
  },
  "dependencies": {
    "body-parser": "^1.13.2",
    "cookie-parser": "~1.3.5",
    "ejs": "*",
    "express": "~4.13.x",
  }
}
天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

全部回复(2)
高洛峰

~x.y.z: 匹配大于 x.y.z 的 z 的最新版
^x.y.z: 匹配大于 x.y.z 的 y.z 的最新版
当 x 为 0 时,^x.y.z 等价于 ~x.y.z,即只会安装z 的最新版本;
当 x 和 y 为 0 时,^x.y.z 等价于 x.y.z,即只会安装x.y.z 版本;

x.y.z 或 <=x.y.z: 大于 x.y.z 的最大版本或与 x.y.z 最接近的版本
x.y.z: 选择 x.y.z

*: 任意版本,一般是最后一次正式发布版本(包括非 latest tag),不是最大版本号版本

PHPz

这是一种叫semver的版本表示法,~^*x都是范围表示方式,参考:semver-ranges

  • < Less than

  • <= Less than or equal to

  • > Greater than

  • >= Greater than or equal to

  • = Equal. If no operator is specified, then equality is assumed, so this operator is optional, but MAY be included.

Any of X, x, or * may be used to "stand in" for one of the numeric values in the [major, minor, patch] tuple.

  • * := >=0.0.0 (Any version satisfies)

  • 1.x := >=1.0.0 <2.0.0 (Matching major version)

  • 1.2.x := >=1.2.0 <1.3.0 (Matching major and minor versions)

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号