Given the rapid pace of changes, it is a given that we’ll need to update our projects’ npm packages eventually. There are several different techniques we can use to update a NodeJs project:
Built-in Utilities
We can check for outdated packages by running the command line npm outdated in the project’s root folder. Executing another command line npm update will update the packages according to the semantic versioning (semver) restraints
Third-Party Tools
1. npm-check-updatesUsing npm-check-updates (ncu) require installing a package:
npm install -g npm-check-updates
Run command line ncu will show the latest packages versions available. Executing ncu -u will only update the package.json file. The packages are updated to the latest versions, ignoring the semver restraints. Afterward, we’ll need to run the additional command line npm install to actually update the npm packages in the node_modules folder.
2. npm-checkUsing npm-check require installing a different package:
npm install -g npm-check
Running the command line npm-check -u will let you interactively select which packages to upgrade. It will upgrade the package(s) to the latest version(s), ignoring the semver restraints.
Yarn
The command yarn outdated will list the latest versions available. Run yarn upgrade-interactive will yield an interactive screen allowing you to select which packages to upgrade.
comments powered by Disqus