Uh oh!
There was an error while loading. Please reload this page.
docs: clarify npm version behavior with prerelease versions - #8735
Conversation
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: npm#8637
a03a52c to
d9dc9e6Compareyashwantbezawada
commented
Nov 16, 2025
Update on Documentation AccuracyAfter thorough testing with actual Actual behavior verified:
The behavior of This matches the original issue report which was specifically about |
wraithgar
commented
Nov 18, 2025
That note seems to break up the flow of the rest of that section, it may need to move to after that paragraph. |
yashwantbezawada
commented
Nov 26, 2025
Moved the note to its own paragraph after the |
Uh oh!
There was an error while loading. Please reload this page.
natesilva
commented
Dec 1, 2025
💯 |
Summary
This PR clarifies the documentation for
npm versionto explicitly describe its behavior when the current version is a prerelease version.Problem
The current documentation states that when using
patch,minor, ormajorarguments, "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), runningnpm version patch(orminor/major) will simply remove the prerelease suffix without incrementing the version number. The result would be1.2.0, not1.2.1.This undocumented behavior has led to:
Solution
Added a note immediately after the existing sentence to clarify this behavior:
Testing
The documentation change is straightforward and doesn't affect code behavior. The example provided matches the actual behavior of the
semver.incfunction from the node-semver package.Fixes#8637