February 21, 2018

How to update all node.js dependencies

The newest version may not always work with a project if it depends on early or specific versions. Use caution following these instructions and be ready to edit or restore your project.

Updating node project dependencies

Find all updates

With the command prompt at the folder of your project check for current versions

npm outdated

The available updates will show, review them, now we can update package.json with:

npm update --save

To include devDependencies requires the command to be:

npm update --save --dev --dev-save

Further, the command only checks the top level, to inspect all levels use:

npm --depth 9999 update --save --dev --dev-save

npm will only update package.json if the package was updated.

To force update all packages, change the versions in package.json to “*” then run the update command

Install updated versions:

Clear the older packages from the node_modules folder for a clean install

del node_modules

Now install the updated versions listed in package.json

npm install

Saving the current (up-to-date) versions

Lastly, save your current exact versions so the project does not change

del npm-shrinkwrap.json

npm shrinkwrap

Now npm install will use the exact versions in npm-shrinkwrap.json.


If you check npm-shrinkwrap.json into git, all installs will use the exact same versions. This is a way to transition out of development (all updates, all the time) to production (no dependency version changes).

Bonus: Latest versions (including beta/unreleased/nightly)

Installing the absolute newest version of a package follows the pattern:

npm install {package-name}@* {save flags?}

Here is an example of the above command used for “express” with “–save”

npm install express@* --save

Leave a Reply

Your email address will not be published. Required fields are marked *