@mdo

Publishing npm packages with dist tags

April 1, 2020

Last month I published the next release of Bootstrap Icons, but I screwed up the distribution tags. Instead of publishing the latest release, I published the next release. That meant my actual latest release wasn’t going to be the version folks get when they updated or installed the package today because next is for upcoming pre-release versions. I’ve screwed this up in the past with Bootstrap proper, too, because I never fully understood them.

Until today, I didn’t even know these things were called distribution (dist) tags. TIL. And today I’m writing it down to remember it for next time.

So how do you use these things or fix problems like this? Turns out npm has you covered with some approachable docs, and you don’t need to release a new version or blow anything up in the process to fix a mistake like this.

npm has dist-tag with some various options to review, add, and remove these tags:

$ npm dist-tag add <pkg>@<version> [<tag>]
$ npm dist-tag rm <pkg> <tag>
$ npm dist-tag ls [<pkg>]

In this case, I had to remove the next dist tag and create a new latest dist tag. It looked like this:

$ npm dist-tag rm bootstrap-icons next
$ npm dist-tag add bootstrap-icons@1.0.0-alpha3 latest

And with that, all was well. If you need a primer on managing alpha or beta releases, check out this Medium article.