npm command parameters --save-dev and both --save What is the difference?

We often encounter when installing npm package --save-dev and --save two command parameters, the two commands are written information to package.json file, both what difference does it make?

1. --save dependencies will package.json the name to the key dependencies, and --save-dev added under devDependencies key.

2.dependencies is dependent on run-time, and devDependencies is dependent on the time of development. In other words, the use of --save-dev package installed after we release is not only used in the development. --Save package using the installation there will depend upon release, for example: the following code:

 1 "devDependencies": {
 2     "babel-core": "6.26.0",
 3     "babel-loader": "7.1.2",
 4     "babel-preset-env": "1.6.1",
 5     "babel-preset-react": "6.24.1",
 6     "css-loader": "0.28.8",
 7     "extract-text-webpack-plugin": "3.0.2",
 8     "file-loader": "^1.1.6",
 9     "html-webpack-plugin": "2.30.1",
10     "node-sass": "^4.7.2",
11     "sass-loader": "6.0.6",
12     "style-loader": "0.19.1",
13     "url-loader": "^0.6.2",
14     "webpack": "3.10.0"
15   },
16   "dependencies": {
17     "react": "16.2.0",
18     "react-dom": "16.2.0"
19   }

In addition, when we use npm install will download the module under dependencies and devDependencies. Use npm install -production or the given value when NODE_ENV production, it is only in the download module dependencies.

Guess you like

Origin www.cnblogs.com/pongx/p/11824472.html