Shipping Prereleases Without Surprising Anyone

Prereleases are how you let early adopters test a big change before everyone gets it. Done right, they reach the people who asked for them and nobody else. Done wrong, a beta becomes the default install for thousands of projects. The difference is usually one flag or one tag, so it is worth understanding how each registry decides what "latest" means.

Prerelease version numbers

Under the semver.org specification, a prerelease is marked with a hyphen and identifiers after the patch number, such as 3.0.0-beta.1 or 3.0.0-rc.2. Prereleases sort before the corresponding release, so 3.0.0-rc.2 comes before 3.0.0. Using dot-separated numeric identifiers, as in beta.10, ensures correct ordering; beta10 would be compared as text.

Python uses PEP 440 instead, where prereleases look like 3.0.0a1, 3.0.0b2 and 3.0.0rc1. The two systems are similar in spirit but not interchangeable, so a project shipping to both registries needs to translate the version string.

How npm keeps prereleases out of default installs

npm uses distribution tags. When someone runs npm install example-lib with no version, npm installs whatever the latest tag points to. Historically, a plain npm publish moved latest to whatever version you had just published, even a prerelease, and that is the classic accident. Newer npm releases are stricter about prereleases published without a tag, but behaviour depends on your npm version, so check the npm Docs for the one you use rather than relying on it. The fix is to publish prereleases under a different tag:

npm version 3.0.0-beta.1 --no-git-tag-version
npm publish --tag next

# testers opt in explicitly
npm install example-lib@next

# inspect the tags
npm dist-tag ls example-lib

Ranges also protect users: per the npm Docs, a range like ^2.4.0 will not match prerelease versions of other releases, so existing users stay on stable versions unless they deliberately opt in.

How Python handles it

pip excludes prereleases by default when resolving a requirement, unless the user passes --pre, pins a prerelease explicitly, or no stable release satisfies the requirement. That makes accidental prerelease installs less likely on PyPI, but it is still worth announcing in the changelog how to try the beta.

A prerelease checklist

  1. Choose a naming scheme (alpha, beta, rc) and stick to it.
  2. On npm, always publish prereleases with --tag, and consider adding it to your CI publish step so it cannot be forgotten.
  3. Check the latest tag immediately after every publish.
  4. Write a short changelog section listing what testers should try and how to report problems.
  5. When the stable version ships, move testers back by announcing it; the next tag can point at the stable release or be removed.

If it goes wrong anyway

If a prerelease does end up as latest, you can point the tag back with npm dist-tag add example-lib@2.4.3 latest. That fixes new installs, but anyone who installed in between keeps the beta in their lockfile. A short notice in the README and changelog helps them find out. For more on how release roles avoid these slips, see who presses publish.

← Back to Home

Subscribe to Our Newsletter

Get the latest updates delivered to your inbox.