Pre-releasing an npm package

Posted . Visible to the public.

You can publish pre-release versions of an npm package.

Naming convention for pre-release versions

An npm package must use Semantic Versioning Show archive.org snapshot 's naming convention for its version. In Semantic Versioning, the version number and pre-release identifier (like rc1) must be separated by a dash, like this:

  • 1.0.0-rc1
  • 2.3.0-alpha2
  • 3.0.0-beta3

Publishing to a pre-release tag

npm packages have multiple "current" releases, identified by "tags". The default tag is latest. It is expected to contain the latest stable version.

When you publish a pre-release version you want to publish to a different tag. This way users of latest don't automatically get your half-baked alpha versions when they upgrade. They need to explictily opt into pre-release versions, as shown below.

A popular tag for pre-releases is next. To publish to the next tag:

npm publish --tag next

Using pre-releases

npm will only install a pre-release if you explicitly use the next tag or name the version.

For instance, to install the latest version of foobar within the next tag:

"dependencies": {
  "foobar": "next"
}

You may also name the pre-release version explicitly:

"dependencies": {
  "foobar": "^2.0.0-rc5"
}

See also

Henning Koch
Last edit
Henning Koch
Keywords
prerelease, alpha, beta, rc
License
Source code in this card is licensed under the MIT License.
Posted by Henning Koch to makandra dev (2021-05-03 09:46)