npm - update all dependencies to latest version
In this article, we would like to show you how to update all dependencies to latest version in npm
.
Quick solution:
xxxxxxxxxx
npm update
or (using hard upgrade):
xxxxxxxxxx
ncu -u && npm install
Where: ncu
should be installed using npm install -g npm-check-updates
Using this section you can update dependencies using embedded npm
command.
Simple steps:
1. Check outdated dependencies using:
xxxxxxxxxx
npm outdated
Note: you can ommit
npm outdated
command and just runnpm update
.
2. Update outdated dependencies using:
xxxxxxxxxx
npm update
Note:
The above solution will update:
- the packages in the
package.json
andpackage-lock.json
files,- the packages in the
node_modules/
directory.
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:
xxxxxxxxxx
npx ncu
Note: you can ommit
ncu
command and just runnpx ncu -u && npm install
.
2. Update outdated dependencies using:
xxxxxxxxxx
npx ncu -u && npm install
Hint:
npx ncu -u
is equivalne fornpx npm-check-updates -u
.
Note:
The above solution will update:
- the packages in the
package.json
file and then inpackage-lock.json
file,- the packages in the
node_modules/
directory.