1 min read

How to change the version of an npm package associated with a specific tag

How to change the version of an npm package associated with a specific tag
Photo by Brett Jordan / Unsplash

If publishing experimental npm packages is a somewhat regular part of your development workflow, you've likely experienced some nerves around publishing that package incorrectly such that it becomes the version that anyone newly installing or upgrading the package gets.

If you find that you accidentally did exactly this because you forgot to add the --tag flag with a different value than latest when running the npm publish command, don't worry - there's a safe way to fix this!

Run this: npm dist-tag add <package>@<version> latest

What this does is it adds the latest tag to the specified version of the package.

I had to do this recently myself and it's really that straightforward. And the best part is you don't need to go through the unpublishing process which has a bunch of scary warnings that make it sound like you're going to accidentally unpublish your whole project.


📫
Enjoy this post? Subscribe to be notified when I publish new content!