HOW TO: Update all npm packages in your project at once

A quick, easy and effortless, albeit, potentially risky way 😅

Jhey Tompkins
4 min readJan 30, 2016

--

Is there a quick and easy out-of-the-box way to update all the npm packages in your project? Yes. Does it quite work as you expect? Not always.

For those in camp TL;DR; write and execute a node script(source below) to rewrite all the versions listed in package.json.

How can I check to see which packages are out of date?

npm outdated

The outdated command will list any packages that are not up to date 👍

Is there not an npm command to upgrade these?

npm update --save/--save-dev

Yes. That is it. It will only update packages so far though. The update function respects semver. For example, if I have a package which is at version 1.3.5, but the latest version is 3.0.5, the package would only update to the latest minor version. In our example, 1.9.9 may be the highest version prior to 2.0.0.

There is good reason for this. New major versions may introduce breaking changes that could break your project. You want to avoid this scenario. The restricted power of npm update promotes manual…

--

--