0

Which of these package version numbers is canonical for NPM?

  • 2.0.0-pre1
  • 2.0.0-pre.1
William Entriken
  • 37,208
  • 23
  • 149
  • 195

1 Answers1

1

NPM just uses the semver package, which follows https://semver.org/, so there isn't any "npm-flavored" semver.

According to semver, both of your examples are valid prerelease versions; the only requirement is that the version number is followed by a hyphen and a series of dot-separated alphanumeric identifiers.

That said, in my opinion, the second is more idiomatic, assuming that you are trying to convey the idea of prerelease version "pre #1". 2.0.0-beta.37, makes it clear that this is beta #37, which comes after prelease beta #36 and before prelease beta #38; as opposed to 2.0.0-beta37, which is ambiguous: beta37 could mean beta #37, or it could be a codename for this particular prerelease, followed by 2.0.0-blue42 etc. etc.

Elliot Nelson
  • 11,371
  • 3
  • 30
  • 44
  • 1
    In addition, mixed alpha numeric fields are compared lexically in ASCII sort order, such that a12 < a2, whereas a.12 > a.2. – jwdonahue Dec 22 '18 at 22:30