Before proceeding with this article, ensure that you have npm installed. Visit node.js to install npm.
To list packages with an outdated version, navigate to the
package.json file and enter the following in a terminal or command:
To update the packages enter the following command:
Note that the above command will only update the packages to the latest minor version. A major version tends to introduce breaking changes, for example, when react-tables was upgraded from version 6 to 7.
In order to upgrade every npm package to the latest version (including latest major version), install the following package globally:
npm install -g npm-check-updates
To show any new version updates for the project, run the following command:
Whenever you need to upgrade a project, run the following command:
The above command will update all packages in the
package.json file to the latest version, including major versions. Run the following command to complete the upgrade:
If the project dependencies where never installed, then run the below command instead of the update:
It is very easy to upgrade all packages in a
package.json file thanks to
npm-check-updates. Follow these steps to upgrade all dependencies to their latest versions (including latest major versions):
ncuto list packages with outdated versions.
ncu -uto upgrade the packages to the latest versions in
npm installto upgrade all packages.
Further information on
npm-check-updates can be found at the following link:
Software versions used in this article
- node v12.16.2
- npm v6.14.4
- ncu v4.1.2