What is the difference between the --save-dev
and --save
when installing a package via npm
?
- 2toster.ru/q/170263 toster.ru/answer?answer_id=559717#comments_list_559717 - HamSter
- Your package (in regular or developmental) gets into different package.json dependencies - Vladimir Gamalyan
4 answers
-S, --save: The package will be displayed in your dependencies
-D, --save-dev: the package will be displayed in your devDependencies
See npm-install for more details.
In the npm 6.5 version, you can not write -save
or -s
, npm itself will add the installed package to you in "dependencies": {}.
From the documentation https://docs.npmjs.com/cli/install :
-P
, --save-prod
: again, save to "dependencies": {}. This is your production code, it will be included in your final product. Add here only those libraries that will be used when running your final product (web page for example).
-D
, --save-dev
: save the package to "devDependencies": {}. These are the packages that you use in the development process, LESS, SASS preprocessors, code validators, JShint Slint, JS: Babel preprocessors. These packages will not be included in the final product.
-O
, --save-optional
: the package will be added to "optionalDependencies": {}. these packages can be used in work, but if they are unavailable or an error occurs during their installation, then npm will just skip them and continue working.
--no-save
: --no-save
package from being saved in package.json.
+ Additional flags:
-E
, --save-exact
: save the version of the package exactly as indicated.
-B
, --save-bundle
: save the package to "bundleDependencies": {}.
If I remember correctly, then when you add -dev
, then in addition to the package everything that it depends on is put.
For example:
bower install jqueryvalidation --save-dev
Will put jqueryvalidation and jquery. because how dependent on her. if you specify without -dev, jquery will not be supplied.
- No, it is not. See the answer @ stas0k - xEdelweiss