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

オープン
#10,289 コメント 0 件 リアクション 0 件 担当者 1 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

@reggi がすでに取り組んでいます。

2026年11月17日 から。

  • #10290 @alphasafal による — オープン

評価

難易度
3/5
見積もり時間
半日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
javascript, nodejs
領域
cli, devtools

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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
主要言語
JavaScript
スター
10.3k
フォーク
5k
平均マージ
4日 11時間
マージ済み PR(30日)
26

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

npm/cli のほかの issue

npm/cli の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。