Read more

Pre-releasing an npm package

Henning Koch
May 03, 2021Software engineer at makandra GmbH

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

Naming convention for pre-release versions

Illustration money motivation

Opscomplete powered by makandra brand

Save money by migrating from AWS to our fully managed hosting in Germany.

  • Trusted by over 100 customers
  • Ready to use with Ruby, Node.js, PHP
  • Proactive management by operations experts
Read more Show archive.org snapshot

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

Posted by Henning Koch to makandra dev (2021-05-03 11:46)