镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

[DOCS] docs for npm version state, incorrectly, that a version will be incremented by 1 #8637

Closed

Description

@natesilva

Is there an existing issue for this?

  • I have searched the existing issues

This is a CLI Docs Problem, not another kind of Docs Problem.

  • This is a CLI Docs Problem.

Description of Problem

In the documentation for npm version, it says:

The newversion argument should be a valid semver string, a valid second argument to semver.inc (one of patch, minor, major, prepatch, preminor, premajor, prerelease), or from-git. In the second case, the existing version will be incremented by 1 in the specified field.

While this is usually the case, it is not always the case. Specifically, npm version patch against a prerelease version will remove the prerelease tag without incrementing the version. This is intentional and documented in node-semver. See https://github.com/npm/node-semver/blob/v7.7.2/classes/semver.js#L258, the section case 'patch':.

// If this is not a pre-release version, it will increment the patch.
// If it is a pre-release it will bump up to the same patch version.
// 1.2.0-5 patches to 1.2.0
// 1.2.0 patches to 1.2.1

Why care?

Because LLMs are reading these docs and don’t understand how version patch works. I have seen:

  • LLMs telling a developer that npm version patch does not remove the prerelease version.
  • That npm version patch always increments the 3rd number (patch) by 1.
  • Proposing incorrect ways of removing the prerelease: npm version --preid='' prerelease (doesn’t do what the LLM thinks)
  • Proposing increasingly ridiculous ways of fixing this (e.g. using sed, writing a script to parse the version number, etc.)

Potential Solution

Update the documentation to explain how npm version patch works.

Affected URL

https://docs.npmjs.com/cli/v11/commands/npm-version

Activity

  1. azadgupta1 commented on Nov 5, 2025

    @azadgupta1

    Hi 👋,
    Can I work on this issue?
    I would like to update the doc for npm version patch behavior when version contains prerelease.

    Please assign this to me.

  2. added a commit that references this issue on Dec 1, 2025
    73688ca
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Documentationdocumentation related issueNeeds Triageneeds review for next steps

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions