package.json 版本说明

Using semantic versioning to specify update types your package can accept

node package.json version

~versionApproximately equivalent to version,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.
^versionCompatible 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.
latestObtains latest release
1.2.x1.2.0, 1.2.1, etc., but not 1.3.0

dependency vs devDependencies

dependency 会被打包到生产环境中

npm install <package...>
yarn add react

devDependencies 只在开发阶段使用,不会打包到生产环境

npm install some_module --save-dev
yarn add <package...> [--dev/-D]


npm install <package...> -g
yarn global add <package...>


// If you plan to publish your package, the most important things in your package.json are the name and version fields as they will be required
The url to the project homepage.
The main field is a module ID that is the primary entry point to your program.
"name": "test-rp",
"version": "",
"homepage": "",
"license" : "BSD-3-Clause",
"main": "foo.js",