docs: clarify npm version behavior with prerelease versions (#8735) · npm/cli@73688ca · GitHub
Skip to content

Commit 73688ca

Browse files
docs: clarify npm version behavior with prerelease versions (#8735)
## Summary This PR clarifies the documentation for `npm version` to explicitly describe its behavior when the current version is a prerelease version. ## Problem The current documentation states that when using `patch`, `minor`, or `major` arguments, "the existing version will be incremented by 1 in the specified field." However, this is incomplete and misleading when the current version is a prerelease. When the current version is a prerelease (e.g., `1.2.0-5`), running `npm version patch` (or `minor`/`major`) will simply remove the prerelease suffix without incrementing the version number. The result would be `1.2.0`, not `1.2.1`. This undocumented behavior has led to: - Developer confusion when the version doesn't increment as expected - Incorrect guidance from LLMs trained on the incomplete documentation ## Solution Added a note immediately after the existing sentence to clarify this behavior: > **Note:** If the current version is a prerelease version, `patch`, `minor`, and `major` will simply remove the prerelease suffix without incrementing the version number. For example, `1.2.0-5` becomes `1.2.0` with `npm version patch`, not `1.2.1`. ## Testing The documentation change is straightforward and doesn't affect code behavior. The example provided matches the actual behavior of the `semver.inc` function from the node-semver package. Fixes #8637
1 parent 4a32606 commit 73688ca

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

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

Lines changed: 2 additions & 0 deletions

0 commit comments

Comments
 (0)