In this post, we'll learn how to use NPM to update a specific Node package.
Sometimes, you need to update a specific Node package, for example if it recently fixed a bug that you need.
To update a specific Node package, you can use the
npm update command.
This command takes a package name as an argument and updates it to the latest version.
For example, here is how to update just
npm update express
You can do this in yarn by using the
yarn upgrade command:
yarn upgrade express
If for some reason you don't want the latest version, perhaps because it may introduce breaking changes to your code, you can alternatively specify a specific version.
This done by adding the version number to the package name.
Here's how to update
express to version
npm update express@4
Here's how to do this in yarn:
yarn upgrade express@4
Lastly, you can also update a specific package to the latest stable version by adding the
@latest suffix to the package name.
Here's how to use the
@latest suffix to update
express to the latest stable version:
npm update express@latest
Here's how that is done in yarn:
yarn upgrade express --latest
In this post, we've seen how we can use
yarn to update Node packages to the latest, a specific version, and the latest stable.
Hopefully, you've found this post useful and enjoyed reading it.
Leave us a message!