DEV Community

Erin Bush
Erin Bush

Posted on

TIL about automatically bumping NPM versions

Do you need to update a bunch of packages? Do they all have a similar scope* or name?

npm-check-updates checks the packages listed in your package.json file, and prints out a list of the packages that can be updated to the latest version.

To install:

npm install -g npm-check-updates
Enter fullscreen mode Exit fullscreen mode

Then, run it in your project folder:

ncu 
Enter fullscreen mode Exit fullscreen mode

You’ll get some output that looks a little something like this:
sample output from npm-check-updates

If you want it to automatically bump the versions in your package.json file you can pass in the update parameter:

ncu -u
Enter fullscreen mode Exit fullscreen mode

You can also run it with a regex string if you are just curious about a certain scope or package:

ncu '/^@npm.*$/' -u
Enter fullscreen mode Exit fullscreen mode

Remember to run npm install afterwards to actually install the packages since npm-check-updates will just update your package.json file.

Presto-chango you've just saved yourself some seriously tedious file changes!


*PS: scopes in npm are useful if you need to group packages by your organization. In the following example “npm” is the scope.

@npm/package-name
Enter fullscreen mode Exit fullscreen mode

This post was originally published on my blog

Top comments (3)

Collapse
 
bycedric profile image
Cedric van Putten •

TIL too! I only knew about npm outdated. Here is the link to the repo:

Collapse
 
lfkwtz profile image
Michael Lefkowitz •