Upgrade/Update All NPM Packages to the Latest Versions
In this short article, we are going to know how to update all NPM packages to the latest versions.
Table of Contents
Package Installation
We need to install a package named npm-check-updates globally. It upgrades your package.json dependencies to the latest versions, ignoring specified versions.
Install the package globally:
npm install -g npm-check-updates
Before upgrading all packages, have a look at the package notes:
- Maintains existing semantic versioning policies, i.e.
"express": "^4.0.0"
to"express": "^5.0.0"
. - Only modifies package.json file. Run
npm install
to update your installed packages and package-lock.json.
Check Available Versions
Show any new dependencies for the project in the current directory by typing ncu
command:
$ ncu
Checking package.json
[====================] 5/5 100%
express 4.12.x → 4.13.x
multer ^0.1.8 → ^1.0.1
react-bootstrap ^0.22.6 → ^0.24.0
react-a11y ^0.1.1 → ^0.2.6
webpack ~1.9.10 → ~1.10.5
Upgrade Versions
Now, run ncu -u
to upgrade package.json packages to the latest versions:
$ ncu -u
Upgrading package.json
[====================] 1/1 100%
express 4.12.x → 4.13.x
Run npm install
to install new versions.
Check Global Packages
To check global packages, run this command:
$ ncu -g
[====================] 5/5 100%
npm 7.20.3 → 7.20.5
ncu itself cannot upgrade global packages.
Run the following to upgrade all global packages:
npm -g install [email protected]
To know more about this package, have a look at their official repository.
That’s all. Thanks for reading.
Md Obydullah
Software Engineer | Ethical Hacker & Cybersecurity...
Md Obydullah is a software engineer and full stack developer specialist at Laravel, Django, Vue.js, Node.js, Android, Linux Server, and Ethichal Hacking.