Are there npm version prerelease identifiers?

timetowonder picture timetowonder · Jun 15, 2017 · Viewed 11.9k times · Source

There is a very handy npm version command. Besides arguments like major, minor and patch it accepts arguments like prerelease, prepatch, etc.
It says in the docs that the commands work in accordance with the semver.inc function.

These pre commands I have a question about.

Say I'm currently at version v1.0.0.
If I run npm version prerelease it will bump version to v1.0.1-0.

Is it possible to provide an extra agrument for a prerelease identifier according to https://github.com/npm/node-semver#prerelease-identifiers?

I wish something like npm version prerelease alpha would bump version to v1.0.1-alpha.0 but that doesn't work.

Answer

Daniel picture Daniel · Aug 17, 2018

Starting with npm 6.4.0 you can use the --preid option of npm version like this:

$ npm version prerelease --preid=alpha
v0.1.1-alpha.0
$ npm version prerelease --preid=alpha
v0.1.1-alpha.1
$ npm version prerelease --preid=alpha
v0.1.1-alpha.2