[BUG] npm publish prints "with tag latest" and accepts a semver-range tag when the tag comes from publishConfig

Aperta
#10,289 0 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

@reggi ci sta già lavorando.

Dal 17/11/2026.

  • #10290 di @alphasafal — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
Mezza giornata
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
javascript, nodejs
Ambito
cli, devtools

Direzione di ricerca

The publish notice and tag handling live in the npm CLI publish command; start by reading the publish implementation where the publishConfig tag is merged with the --tag option, and the dist-tag code that rejects SemVer ranges. Reproduce with the steps in the issue using a dry run. Done when the notice prints the tag actually used and a SemVer-range publishConfig tag is refused like --tag 1.x; note that pull request 10290 already targets this, so check it before starting.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Bug cmd:publish Priority 3 Triage Requested
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
This is not just a request to bump a dependency for a CVE
  • This is not solely a request to bump a dependency for a CVE
Current Behavior

With "publishConfig": { "tag": "next" } in package.json, npm publish prints Publishing to https://registry.npmjs.org/ with tag latest, but the package is actually published under the next dist-tag.

With "publishConfig": { "tag": "1.x" }, the publish goes through and creates a 1.x dist-tag.
The same tag passed as --tag 1.x, or with npm dist-tag add, is refused with Tag name must not be a valid SemVer range: 1.x.

Expected Behavior

The notice should show the tag that is actually used (next), and a semver-range tag from publishConfig should be refused the same way as --tag 1.x.

Steps To Reproduce
mkdir pc-tag && cd pc-tag
echo '{"name":"publishconfig-tag-demo","version":"1.0.0","publishConfig":{"tag":"next"}}' > package.json
npm publish --dry-run
# npm notice Publishing to https://registry.npmjs.org/ with tag latest and default access (dry-run)

# change the tag to a semver range
echo '{"name":"publishconfig-tag-demo","version":"1.0.0","publishConfig":{"tag":"1.x"}}' > package.json
npm publish --dry-run
# succeeds, still says "with tag latest"

npm publish --dry-run --tag 1.x
# npm error Tag name must not be a valid SemVer range: 1.x
Environment
  • npm: 12.2.2 (also on the latest branch at 8f92e74)
  • Node.js: 22.23.4
  • OS Name: Linux
  • npm config: defaults
Lingua principale
JavaScript
Stelle
10.3k
Fork
5k
Merge medio
4g 11h
PR unite (30g)
26

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di npm/cli

Tutte le issue di npm/cli

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.