Updating npm packages versions in package.json

I chose to use npm-check-updates to check for available updates of packages in my package.json files, and it always works without issues, so I guess I can recommend it.

I'm also using this as a reminder for my own use… 😁

Here are the steps:

Install npm-check-updates

Section titled Install

npm-check-updates is a npm package:

npm install -g npm-check-updates

Check for available updates

Section titled Check for available updates

Run ncu (as in npm-check-update) to list updatable packages:

ncu

Automate update for all packages

Section titled Automate update for all packages

If everything looks fine, update all package versions in your package.json file at once:

ncu -u

If you have doubts about at least one of the package versions, update your package.json file manually to test the results progressively.

Don't forget to actually update the installed packages

Section titled Don't forget to actually update the installed packages

npm-check-updates "only" updates the version numbers in your package.json file.

You now have to really install them.

Make sure current version of your package-lock.json file is versioned (for any rollback need), then run:

npm install

What about salita?

Section titled What about

There is also salita, which has a few differences.

I prefer npm-check-update because its default behavior prevents accidental modification of the package.json file.

5 Webmentions

2 likes

3 replies

  1. Yvain Liechti avatar Yvain Liechti
    I think you should mention grenkeeper or dependabot. And I prefer npmjs.com/package/npm-ch… to ncu now
  2. Hank Drury avatar Hank Drury
    What a cool picture.
  3. Nicolas Hoizey avatar Nicolas Hoizey
    Thanks!

    I see there's an issue with the apostrophe… 😅