Difference between -- save-dev and -- save when npm install
Description of two fields in package. json
I have been using the npm package manager. I have made some analysis on the differences between npm install module -- save-dev and npm install module -- save:
Dependencies
The dependencies attribute is declared in a simple object to control the package name within a certain version range. The version range is a string and can be separated by one or more spaces. Dependencied can also be specified as a package address or a git URL address.
Do not write the test tool or transpilers escape tool (babel, webpack, gulp, postcss...) into dependencies. (These should be written to devDependencies) configuration, because npm will download dependencies in dependencies when installing the package in other projects.
DevDependencies
If your package is dependent on or installed by others, npm install in the main project of the other party will not install the npm package in devDependencies in the dependency package, therefore, if some packages that your project depends on do not have to be installed when using this project, place the packages in devDependencies.
* ** Overall function comparison ****
Npm install module:
- The module package is installed in the node_modules directory.
- Package. json is not modified
- When the npm install command is run later, the module package is not automatically installed.
Npm install module -- save
- The module package is installed in the node_modules directory.
- The package. json is modified to add the module name and version number to the dependencies section.
- When you run the npm install command, the module package is automatically installed.
- When you run npm install -- production or specify the NODE_ENV variable value as production, the module is automatically installed in the node_modules directory, that is, the package is installed when the online environment is running.
Npm install module -- save-dev
- The module package is installed in the node_modules directory.
- The package. json is modified to add the module name and version number to the devDependencies section.
- When you run the npm install command, the module package is automatically installed.
- When you run npm install -- production or specify the NODE_ENV variable value as production, msbuild will not be automatically installed into the node_modules directory, that is, the online environment will not be installed.
First, -- save and -- save-dev save the steps for manually modifying the package. json file. Some of our packaging tools and non-project dependencies are stored in devDependencies.
This article permanently updates link: https://www.bkjia.com/Linux/2018-03/151499.htm