Summary
To check for outdated packages, enter the following command in your terminal:
npm outdated
To update all of your outdated packages, enter the following command in your terminal:
npm update
To update a single outdated package, enter the following command in your terminal:
npm update package-name
Details
Check for outdated packages
Before updating any packages, you should first check which packages are outdated. To do this, enter the following command in your terminal:
npm outdated
If you have any outdated packages, you should see something like the following print out. In my case, my browser-sync
package is out-of-date.
Package Current Wanted Latest Location
browser-sync 2.26.5 2.26.7 2.26.7 my-project
Update a single local package
If you want to update a single package, you can add the name of the package that you want to update to the command. In my example, if I want to update browser-sync
then I would enter the following command in my terminal:
npm update browser-sync
After running the update command, you can run the npm outdated
command one more time to make sure the package was updated. If you updated a single package, that package shouldn’t appear in the list, and if all of your packages are up-to-date, you shouldn’t see anything print out at all.
Update all local packages
If you want to update all of your outdated packages, enter the following command in your terminal:
npm update
Reference
Updating packages downloaded from the registry | npm Documentation