Skip to content

[BUG] npm version from-git removes prerelease stanzas #8275

@aendra-rininsland

Description

@aendra-rininsland

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

If I have a git tag like v2.1.0-alpha.1 and I run npm version from-git --no-git-tag-version, it rewrites the tag's version to v2.1.0 and puts that into package.json's version property.

Expected Behavior

The prerelease stanza of the Git tag should be preserved when running npm version from-git. The current behaviour unexpectedly removes it. This led to a not-at-all-fun experience this morning due to inadvertently publishing a prerelease version as a stable version.

At the very least, this behaviour should be documented.

Steps To Reproduce

  1. git tag v1.0.0-alpha.1
  2. npm version from-git --no-git-tag-version
  3. The version property of package.json will now read 1.0.0

Environment

  • npm: 11.3.0
  • Node.js: 22.15.0
  • OS Name: circleci/[email protected]
  • System Model Name: CircleCI
  • npm config:
; node bin location = /usr/local/bin/node
; node version = v22.15.0
; npm local prefix = /home/circleci/project
; npm version = 11.3.0
; cwd = /home/circleci/project
; HOME = /home/circleci
; Run `npm config ls -l` to show all defaults.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingPriority 2secondary priority issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions