How to update all Node dependencies to their latest version

Update all node dependencies

For the first time last week, i received a “Security Alert Digest” email from Github.

Inside were all the dependencies of a project, gatsby-starter, that had known vulnerabilities. It listed the name of the dependency, its version, and the version i should upgrade to to be safe. Okay.

Github secret alert digest screenshot

I started thinking, wait, how the heck do i upgrade all of the dependencies at once? There were about 14 or so.

In case you’re wondering how to do so, too, here you go.

npm outdated command
Run this command to get a list of what’s outdated.

First off, running npm update won’t update major releases by standard package.json rules. You’ll need to install the npm-check-updates package globally. It’s used to let npm know to install  the minor dev and devDependencies for each of your packages in the node_modules folder.

npm install -g npm-check-updates

then run ncu -u

then npm install. Boom.

Hope that helps!

Cheers and peace.

(Visited 226 times, 1 visits today)

If you found this post useful ...

Buy Me a Coffee logo
Wondering why you keep seeing lower-cased 'i' in my posts? Read -> Why ‘i’ is not capitalized