Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node.js中package.json中库版本号详解 #178

Open
louzhedong opened this issue Sep 17, 2019 · 0 comments
Open

Node.js中package.json中库版本号详解 #178

louzhedong opened this issue Sep 17, 2019 · 0 comments

Comments

@louzhedong
Copy link
Owner

当我们看package.json文件时,会看到以下几种版本号的表示方式,有的是一个^,有的是~,而有的就是单纯的数字
"babel-core": "7.0.0-bridge.0",
"babel-eslint": "^10.0.1",
"babel-jest": "~23.6.0",

当我们使用npm install —save 安装时,优先会使用插入符号(^)而不是波浪线(~)

版本号的含义

node中的版本号都是由3个数字用(.)连接起来,三个数字的含义分别为major, minor, patch

例如,10.0.1对应major, minor, patch就是:10是marjor version, 0是minor version, 1是patch version

其中:

major version: 这个版本号变化了表示有了一个不可以和上个版本兼容的更新

minor version: 这个版本号变化了表示增加了新功能,并可以向后兼容

patch version: 这个版本号变化了表示修复了bug, 并可以向后兼容

~ 和 ^ 的区别

波浪符号(~):会更新到当前minor version(中间的数字)的最新版本,即23.6.0会更新到23.6.x的最新版本,如果出了一个23.7.0,则不会自动升级

插入符号(^): 会更新到当前major version(前面的数字)的最新版本,即23.6.0会更新到23.x.x的最新版本,但是不会更新到24.x.x

最后如果前面不加符号,就安装特定版本的库,不会自动安装更高版本号的库

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant