How to Update a Specific Node package using NPM - Sabe.io (2023)

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.

(Video) How to Safely Update NPM Packages

For example, here is how to update just express:

npm update express

You can do this in yarn by using the yarn upgrade command:

yarn 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:

(Video) Updating project dependencies, npm outdated

npm update [emailprotected]

Here's how to do this in yarn:

yarn upgrade [emailprotected]

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:

npm update [emailprotected]

Here's how that is done in yarn:

yarn 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.

(Video) How to update your Node.js dependencies [10 of 26] | Node.js for Beginners

Hopefully, you've found this post useful and enjoyed reading it.

Happy coding!

If you want to learn about web development, founding a start-up, bootstrapping a SaaS, and more, follow me on Twitter! You can also join the conversation over at our official Discord!

Give feedback on this page, tweet at us, or join our Discord!

×

Leave us a message!

(Video) NodeJS | NPM | InquirerJS Beginner Tutorial

(Video) NPM Node Package Manager Modules | NPM Tutorial for Beginners

Videos

1. Test Node Modules Locally | npm pack and npm link #nodejs #npm #node
(varelycode)
2. How npm resolves dependency hell | Must know!
(Mayank Srivastava)
3. How to Update All NPM Dependencies At Once
(Çelik Köseoğlu)
4. NPM Crash Course | Everything you need to know #javascript #npm
(Cules Coding)
5. Why Package-lock.json is getting generate after NPM Install | Package.json vs Package-lock.json
(Raheem's view)
6. How I Upgrade Dependencies in a Node Project: yarn upgrade-interactive
(Kevin Wade)
Top Articles
Latest Posts
Article information

Author: Margart Wisoky

Last Updated: 04/19/2023

Views: 5783

Rating: 4.8 / 5 (58 voted)

Reviews: 81% of readers found this page helpful

Author information

Name: Margart Wisoky

Birthday: 1993-05-13

Address: 2113 Abernathy Knoll, New Tamerafurt, CT 66893-2169

Phone: +25815234346805

Job: Central Developer

Hobby: Machining, Pottery, Rafting, Cosplaying, Jogging, Taekwondo, Scouting

Introduction: My name is Margart Wisoky, I am a gorgeous, shiny, successful, beautiful, adventurous, excited, pleasant person who loves writing and wants to share my knowledge and understanding with you.