[DOCS] Explain registry reads and registry selection for npm publish --dry-run

未关闭 适合新手
#10,386 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
85/100
Issue 类型
文档
描述清晰度
描述清楚
活跃度
活跃
领域
cli, documentation

调研方向

从 issue 中链接的 npm v12 publish 参考文档开始,检查它如何描述 --dry-run、registry 选择和离线行为。记录 dry-run 验证可以读取软件包版本,解释 issue 中描述的 registry 优先级,并加入本地 tarball 示例。完成标准是参考文档说明版本查询、registry 选择,以及离线模式无法验证的内容。

由索引模型根据 Issue 内容生成。

描述

Is there an existing issue for this?
  • I have searched the existing issues
This is a CLI Docs Enhancement, not another kind of Docs Enhancement.
  • This is a CLI Docs Enhancement.
Description of Problem

The publish reference could explain that --dry-run skips the publish write while still allowing registry reads and version checks.
The same tarball can pass or fail based on which versions a registry reports.
Someone using a dry run to check a package before publishing can't tell from the docs which registry it will ask.

We reproduced this with npm 12.2.3 and Node.js 26.13.1 using loopback registries.
Set the package name and version to [email protected].
Set publishConfig.registry and npm_config_registry to different registries.
Use an isolated empty cache for each run and set npm_config_update_notifier=false to measure requests from publish itself.

npm pack --ignore-scripts
npm publish ./example-dry-run-0.0.0.tgz --dry-run --ignore-scripts

The dry run sent GET /example-dry-run to the registry in publishConfig and made no upload request.
Returning {"versions":{}} let it pass.
Returning {"versions":{"1.0.0":{"name":"example-dry-run","version":"1.0.0"}}} made it fail with “Cannot implicitly apply the "latest" tag.”
An explicit --registry pointed the version lookup at that registry.
With an empty cache, --offline stopped the package lookup.
With the notifier enabled outside CI, npm still requested /npm from the registry set in the environment.

Potential Solution

Document the version lookup and the registry order for this unscoped package.
An explicit --registry wins over publishConfig.registry, which wins over npm_config_registry.
Give a local-tarball example with --offline --no-update-notifier and explain that an offline run cannot confirm versions on the remote registry.
The maintainers confirmed that dry-run validation is intentional in the npm 11 version-check report.

Docs URL

https://docs.npmjs.com/cli/v12/commands/npm-publish/

I'm happy to open a pull request with the documentation and a focused loopback-registry test if that would help.


Posted by Claude Opus 5.5 on behalf of @boblangley after review

主要语言
JavaScript
星标
10.3k
派生
5k
平均合并
4 天 11 小时
30 天内合并 PR
26

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

npm/cli 的其他 Issue

查看 npm/cli 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。