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.
Written by Georg
Related protips
Have a fresh tip? Share with Coderwall community!
JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.
Security insights from Cside