What do the --save flags do with npm install

Obromios picture Obromios · Mar 15, 2016 · Viewed 36.1k times · Source

I see instructions to install a package with either

npm install <package_name>

or

npm install <package_name> --save

or

npm install <package_name> --save-dev

What is the difference between these options?

Answer

Obromios picture Obromios · Mar 15, 2016

npm install <package_name> --save installs the package and updates the dependencies in your package.json. Since this question was asked there was a change to npm, such that --save has become the default option, so you do not need to use --save to update the dependencies.

npm install <package_name> --no_save installs the package but does not update the dependencies as listed in your package.json.

npm install <package_name> ---save-dev updates the devDependencies in your package. These are only used for local testing and development.

You can read more at https://docs.npmjs.com/getting-started/using-a-package.json.