clubmate.fi

A good[ish] website

Web development blog, loads of UI and JavaScript topics

How to easily keep a JavaScript project’s packages up to date

Filed under: Tooling— Tagged with: npm

Here’s how to fly through your package update chores using automated tools.

Ah, the pain ot combing through your package.json and comparing version numbers in npmjs.org. This is a task that is relatively easy to automate.

The npm-check package

npm-check is an absolutely brilliant package! Start by Installing it globally:

$ npm i -f npm-check

The run it:

$ npm-check -us

And you get a prompt showing you the outdated packages. Then press space to select the package, and hit enter to start the update process.

npm-check package update helper
npm-check shows you outdated packages

Here’s the explanations for the flags:

-u
Interactive update.
-s
Skip check for unused packages.

Option 2: npm-check-updates

The pakcage npm-check-updates does pretty much the same as npm-check, but with one extra step: you first update the package file, then update the packages.

Install globally:

$ npm i -g npm-check-updates

cd into your project and run it:

$ npm-check-updates

That’ll spew out a list of outdated packages for you to inspect. Then tell it to update the packages.json file:

$ npm-check-updates -u

When it’s done, use the npm’s built in update command:

$ npm update

Conclusions

Using npm-check has worked super good for me. This has really helped the package update anxiety.

Comments would go here, but the commenting system isn’t ready yet, sorry. Tweet me @hiljaa if you want to make a correction etc.

  • © 2021 Antti Hiljá
  • About
  • Follow me in Twatter → @hiljaa
  • All rights reserved yadda yadda.
  • I can put just about anything here, no one reads the footer anyways.
  • I love u!