In this short article, we are going to know how to update all NPM packages to the latest versions.
Table of Contents
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.
- Only modifies package.json file. Run
npm installto 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 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
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
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. 🙂