esedic
1/14/2019 - 1:54 PM

Updating packages with npm and yarn

Updating packages with npm and yarn

Below are a set of commands to list globally installed packages and a set of commands to updated them.

npm
To update npm packages we have npm-check. First you will have to install it globally

npm i npm-check -g
Then to list packages that need to be updated

npm-check -gu
We pass -g flag to do a global search, then u flag to update. This will give us an interactive menu where you can move up/down the list
of packages, then press space bar to select them, finally press Enter key to update the selected packages.

Now to list all of your packages

npm list -g --depth=0
Again we pass the -g flag to do a global search and — depth=0 to give us a clean list. If you don’t then it will give us a very verbose
list, listing all of the dependencies for each package as well.

Yarn
With yarn we don’t have to install another package, just run

yarn global upgrade-interactive
We pass the global flag to do a global search. And as with npm, you can move up/down the list of packages, then press space bar to 
select them, finally press Enter key to update the selected packages.

To list global packages

yarn global list