Description
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
NOTE: This is rather a footgun than a bug
This was reported in npm/npm#13248 and has been ignored and never re-opened since, even though the problem clearly still exists. Following is the (adapted) description from the issues' original author. I have verified that this behaviour is still present.
Running npm version premajor && npm publish
will tag the premajor version as latest
by default. I confirmed this happens when running all pre-release options: premajor | preminor | prepatch | prerelease
.
As pointed out in npm/npm#10189, there are valid reasons that authors would want to tag pre-release versions as latest
. However, I think that this is not good default behaviour (though it is documented: "Publishing a package sets the latest
tag to the published version unless the --tag
option is used. For example, npm publish --tag=beta
.")
Semver documentation states:
A pre-release version indicates that the version is unstable and might not satisfy the intended compatibility requirements as denoted by its associated normal version. Examples: 1.0.0-alpha, 1.0.0-alpha.1, 1.0.0-0.3.7, 1.0.0-x.7.z.92.
Source: http://semver.org/#spec-item-9
Expected Behavior
I propose that the latest
tag only be set if the version to be published is not a pre-release version. Or, at the very least, there should be a warning about this.
Steps To Reproduce
- While in any package directory...
- Run
npm version prepatch
or... preminor
or... premajor
or... prerelease
or set a pre-release version manually - Run
npm publish
- See that the package gets published to the
latest
tag without any fuss
Environment
- npm: 10.5.2
- Node.js: 20.13.0
- OS Name: macOS Ventura 13.6.6
- System Model Name: MacBook Pro 14-inch 2023 M2 Pro 32GB RAM
- npm config:
; "project" config from /Users/nikitakaramov/Code/@kytta/npmtest/.npmrc
@kytta:registry = (redacted)
//(redacted)/:_authToken = (protected)
; "env" config from environment
userconfig = "/Users/nikitakaramov/.config/npm/npmrc"
; node bin location = /Users/nikitakaramov/.local/share/mise/installs/node/20.13.0/bin/node
; node version = v20.13.0
; npm local prefix = /Users/nikitakaramov/Code/@kytta/npmtest
; npm version = 10.5.2
; cwd = /Users/nikitakaramov/Code/@kytta/npmtest
; HOME = /Users/nikitakaramov
; Run `npm config ls -l` to show all defaults.