Say I want to generate a pre-release NPM version.
Originally I have this:
"version": "0.0.1"
I tried:
npm version prepatch
npm version prepatch
npm version preminor
npm version preminor
that gave me this:
v0.0.2-0
v0.0.3-0
v0.1.0-0
v0.2.0-0
Those don't look useful to me, because they always bump up the actual version number, meaning npm version patch
and npm version prepatch
don't seem to be making much difference.
So my question is - is there an official way to generate an alpha/beta version with npm at the command line?
npm version minor-alpha
npm version minor-beta
npm version minor-rc
something like that?
UPDATE
As of npm
6.3.0-next.0
you can now use--preid
when tagging pre-releases withversion
.NPM Link: https://docs.npmjs.com/cli/version
Original answer
Sadly (and a little bit ironic) npm does not fully support all the features of semver!
What you need is a feature called pre-id, found in the semver spec #9. I have submitted a PR to npm about it but it was rejected. https://github.com/npm/npm/pull/13794
preids basically allow you to specify an id for a prerelease, for example:
Forrest rejected this proposal in a comment writing this:
As he recommends, to get this working you should be using a tool that does support full semver versioning. I presonally recommend semver package, found in the npm documentation itself here https://docs.npmjs.com/misc/semver
Looks like:
npm version prerelease
is basically what I am looking for, but this doesn't add alpha/beta/rc to the version, it just does this
x.y.z-n
.