Last Updated: January 28, 2019
·
25.71K
· calamari

Install npm packages with --save or --save-dev

I am not quite sure since when npm has this arguments and why I missed that, but they are really great.

If you npm install something with --saveor --save-dev, it will not only install it, it will also put it in the right place within your package.json file.

So, go ahead and try for example this one:

npm install express --save 

And you will see it put "express": "~3.4.4" at the end of the dependencies block within your package.json. It will always use the ~ notation with the full version number, so you will not have problems reinstalling the same version again on different systems.

Or put the dependcy into the devDependenciessection:

npm install supertest --save-dev

If you write a new application and are trying out differnt npm packages, it really is a time safer.