Skip to content

Commit d9dc9e6

Browse files
docs: clarify npm version patch behavior with prerelease versions
When the current version is a prerelease (e.g., 1.2.0-5), running npm version patch will remove the prerelease suffix without incrementing the patch number (e.g., 1.2.0-5 becomes 1.2.0 with npm version patch, not 1.2.1). This behavior was not documented, leading to confusion for developers and incorrect guidance from LLMs trained on the incomplete documentation. Note: The behavior of minor and major with prerelease versions is more complex and depends on the current version numbers, so this change focuses specifically on patch behavior which is consistent. Fixes: #8637
1 parent cbc6fa9 commit d9dc9e6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

docs/lib/content/commands/npm-version.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Run this in a package directory to bump the version and write the new data back
1818
`npm-shrinkwrap.json`.
1919

2020
The `newversion` argument should be a valid semver string, a valid second argument to [semver.inc](https://github.com/npm/node-semver#functions) (one of `patch`, `minor`, `major`, `prepatch`, `preminor`, `premajor`, `prerelease`), or `from-git`.
21-
In the second case, the existing version will be incremented by 1 in the specified field.
21+
In the second case, the existing version will be incremented by 1 in the specified field. **Note:** If the current version is a prerelease version, `patch` will simply remove the prerelease suffix without incrementing the patch version number. For example, `1.2.0-5` becomes `1.2.0` with `npm version patch`, not `1.2.1`.
2222
`from-git` will try to read the latest git tag, and use that as the new npm version.
2323

2424
If run in a git repo, it will also create a version commit and tag.

0 commit comments

Comments
 (0)