Updating npm packages in project

Conquer this mess!!

Posted by Piotr Smyda on August 11, 2017

Keeping up with JS projects packages is hard but not with npm.

Every time I need to check if there are newer version for projects dependencies or have to update because of some important feature changes I do this:
1st let's check what packages versions we have in a project:

npm outdated

This will generate a list of all packages that are currently installed, their current and latest versions. From that list we can go to updating.
There are few ways we can take to complete update.
To update all dependencies in a project at once we can just run

npm update --save

There was a bug that duplicated devDependencies - I believe it is fixed but If you have problems with this simple command you can use

npm update -D && npm update -S

Second option is to just update packages one by one using:

npm i {package-name} --save

Remember to add --save parameter to persist changes in package.json file.
Also you can always specify package version you want to install by placing its number after "@" sign like this:

npm i express@3.0.0 --save