package.json

package.json

http://javascript.ruanyifeng.com/nodejs/packagejson.html

版本号

比如下面的package

{
  "dependencies": {
    "babel-core": "^5.8.25",
    "babel-loader": "^5.3.2",
    "browserslist": "^1.0.1",
    "bundle-loader": "^0.5.4",
    "css-loader": "~0.16.0",
    "file-loader": "~0.8.4",
    "jquery": "~2.1.4",
    "jsx-loader": "~0.13.2",
    "num2fraction": "^1.2.2",
    "react": "~0.13.3",
    "react-hot-loader": "^1.2.8",
    "react-router": "^0.13.3",
    "style-loader": "~0.12.3",
    "url-loader": "~0.5.6",
    "webpack": "~1.11.0",
    "webpack-dev-server": "^1.10.1"
  },
  "devDependencies": {
    "webpack": "^1.11.0"
  }
}
  • 指定版本:比如1.2.2,遵循“大版本.次要版本.小版本”的格式规定,安装时只安装指定版本。
  • 波浪号(tilde)+指定版本:比如~1.2.2,表示安装1.2.x的最新版本(不低于1.2.2),但是不安装1.3.x,也就是说安装时不改变大版本号和次要版本号。
  • 插入号(caret)+指定版本:
    比如ˆ1.2.2,表示安装1.x.x的最新版本(不低于1.2.2),但是不安装2.x.x,也就是说安装时不改变大版本号。

    需要注意的是,如果大版本号为0,则插入号的行为与波浪号相同,这是因为此时处于开发阶段,即使是次要版本号变动,也可能带来程序的不兼容。

  • latest:安装最新版本

参考
http://stackoverflow.com/questions/22343224/difference-between-tilde-and-caret-in-package-json

~version "Approximately equivalent to version" See npm semver - Tilde Ranges & semver (7)
^version "Compatible with version" See npm semver - Caret Ranges & semver (7)
version Must match version exactly

version Must be greater than version
=version etc
<version
<=version
1.2.x 1.2.0, 1.2.1, etc., but not 1.3.0
http://sometarballurl (this may be the URL of a tarball which will be downloaded and installed locally

  • Matches any version

你可能感兴趣的:(package.json)