Languages
[Edit]
EN

npm - update all dependencies to latest version

3 points
Created by:
Dragontry
731

In this article, we would like to show you how to update all dependencies to latest version in npm.

Quick solution:

npm update

or (using hard upgrade):

ncu -u && npm install

Where: ncu should be installed using npm install -g npm-check-updates

 

Embedded solution

Using this section you can update dependencies using embedded npm command.

Simple steps:

1. Check outdated dependencies using:

npm outdated

Note: you can ommit npm outdated command and just run npm update.

 

2. Update outdated dependencies using:

npm update

Note:

The above solution will update:

  • the packages in the package.json and package-lock.json files,
  • the packages in the node_modules/ directory.

 

External solution

Using this section you can update dependencies using external ncu command. ncu should be installed using npm install -g npm-check-updates.

Simple steps:

1. Check outdated dependencies using:

npx ncu

Note: you can ommit ncu command and just run npx ncu -u && npm install.

 

2. Update outdated dependencies using:

npx ncu -u && npm install

Hint: npx ncu -u is equivalne for npx npm-check-updates -u.

Note:

The above solution will update:

  • the packages in the package.json file and then in package-lock.json file,
  • the packages in the node_modules/ directory.

 

References

  1. npm-update - npm Docs
  2. npm-check-updates - npm repository

Alternative titles

  1. npm - update all packages to latest version
  2. Node.js - update all dependencies to latest version
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join