Which of these package version numbers is canonical for NPM?
2.0.0-pre1
2.0.0-pre.1
Which of these package version numbers is canonical for NPM?
2.0.0-pre1
2.0.0-pre.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.