I see instructions to install a package with either
npm install
or
npm install --save
The --save
flag no longer serves a purpose.
Previously, as the other answers noted, the --save
flag would update the dependencies in the project's package.json
file, but npm install
now includes this functionality by default.
At this point if you want to prevent npm install
from saving dependencies, you have to use the --no-save
flag.
Thanks to Coruscate5 for mentioning this in their comment.
More info in the npm-install documentation:
npm install saves any specified packages into dependencies by default. Additionally, you can control where and how they get saved with some additional flags:
-P, --save-prod: Package will appear in your dependencies. This is the default unless -D or -O are present.
-D, --save-dev: Package will appear in your devDependencies.
-O, --save-optional: Package will appear in your optionalDependencies.
--no-save: Prevents saving to dependencies.
When using any of the above options to save dependencies to your package.json, there are two additional, optional flags:
-E, --save-exact: Saved dependencies will be configured with an exact version rather than using npm’s default semver range operator.
-B, --save-bundle: Saved dependencies will also be added to your bundleDependencies list.