npm install --save, what is the use of not saving

I just learned a nice trick from Jonathan Mills' JavaScript Best Practices course on Pluralsight. From the terminal:
npm config set save=true
Now I don't need to remember --save anymore. And I also now use
npm config set save-exact=true
Because I want the exact version of the package not the ^ prefix.


  1. You would have a scenario such as you need some module to install without adding dependency to package.json file, for ex. you just want to try some module, and not sure you would be really using that module in production or while deploying, so instead adding the module dependency to package.json, just give it a try without using --save. this is why npm install without --save exists.

  2. But For most of your modules you might require using --save, for ex. npm install express --save, in this case you surely know that you are going to use express for you application.

  3. The other scenario, for not using --save, would be, npm install heapdump or npm install nodemon, I would use it for testing my apps performance, but not add a dependency in the package.json :)

  4. Also, As @surajck said in comment below: when you are doing global installs, in that case adding dependencies using --save, to the package.json would not make sense.

Tags:

Node.Js

Npm