How to Update a Specific Node package using NPM
Table of Contents
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.
Updating a Specific Package to Latest
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 express
:
BASHnpm update express
You can do this in yarn by using the yarn upgrade
command:
BASHyarn upgrade express
Update a Specific Package to Specific Version
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 4.0
:
BASHnpm update express@4
Here's how to do this in yarn:
BASHyarn upgrade express@4
Updating a Specific Package to Latest Stable
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:
BASHnpm update express@latest
Here's how that is done in yarn:
BASHyarn upgrade express --latest
Conclusion
In this post, we've seen how we can use npm
and 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.
Happy coding!
- Getting Started with Svelte
- Git Tutorial: Learn how to use Version Control
- How to Serve Static Files with Nginx and Docker
- Best Visual Studio Code Extensions for 2022
- How to build a Discord bot using TypeScript
- How to deploy a Deno app using Docker
- How to deploy an Express app using Docker
- How to deploy a Node app using Docker
- Learn how to use v-model with a custom Vue component
- Using Puppeteer and Jest for End-to-End Testing
- Learn how to build a Slack Bot using Node.js
- How To Create a Modal Popup Box with CSS and JavaScript