Safely update your packages

22 March 2022

Safely update your packages
Safely update your packages

Updating packages is essential to get the latest features and reduce security issues. npm-check-updates is an npm package that makes the process of updating packages easier. Here's my flow of how I update packages.

Install npm-check-updates

If you don't want to install the package globally, you can run it with npx.

npm install -g npm-check-updates

What does it do?

When you run the command below, you will get an overview of all packages that have updates available.

npx ncu

Safely updating packages

We will be updating packages in turns. First, we update the least impactful, followed by minor versions and last but not least, the packages that have breaking changes.

Before moving to the next step, we run npm i, checking if something breaks.


npx ncu -u -t patch

Minor versions

npx ncu -u -t minor

Major versions

A change of major version usually indicates that there are breaking changes. So look up the package and go and check the release notes. Once you do, you have two options.

You could update all the major versions with npx ncu -u -t majorBut it's better to update them one by one.

npx ncu -u -f eslint

The param -f or --filter makes it so you can filter the packages you want to update.

After that, you can proceed to the next major package that needs an update.