Node.js : Updating NPM and packages

Since npm itself is a Node.js module, it can be updated using itself. If OS is Windows must be running command prompt as Admin

npm install -g npm@latest

If you want to check for updated versions you can do:

npm outdated

In order to update a specific package:

npm update <package name>

This will update the package to the latest version according to the restrictions in package.json

In case you also want to lock the updated version in package.json:

npm update <package name> --save

Buy Me A Coffee

With all that being said, I highly recommend you keep learning!

Thank you for reading this article. Please feel free to connect with me on LinkedIn and Twitter.