Commit 73688ca
authored
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 #86371 parent 4a32606 commit 73688ca
1 file changed
+2
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
| |||
0 commit comments