What is the real use of npm install --save

What is the real use of npm install –save?

Before version 5

Before version 5, NPM simply installed a package under node_modules by default. When you were trying to install dependencies for your app/module, you would need to first install them, and then add them (along with the appropriate version number) to the dependencies section of your package.json.

npm install --save will install the package and update your package.json, so that in the future when you or someone else runs npm install, they will install the package without needing to specify it. package.json keeps track of your project’s dependencies, so that you only have to run npm install after a fresh clone/pull/deployment/reinstall/whatever, instead of needing to manually install all dependencies by specifying their names.

In addition, there are the complementary options --save-dev and --save-optional which save the package under devDependencies and optionalDependencies, respectively. This is useful when installing development-only packages, like grunt or your testing library.

Now

As of npm 5.0.0, installed modules are added as a dependency by default, so the --save option is no longer needed. The other save options still exist and are listed in the documentation for npm install.