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

Đang mở Phù hợp với người mới
#10,386 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
85/100
Loại issue
Tài liệu
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
javascript, node.js
Lĩnh vực
cli, documentation

Hướng nghiên cứu

Bắt đầu với tài liệu tham khảo publish của npm v12 được liên kết trong issue và kiểm tra cách tài liệu mô tả --dry-run, việc chọn registry và hành vi khi offline. Ghi lại rằng bước xác thực dry-run có thể đọc phiên bản gói, giải thích mức ưu tiên registry được mô tả trong issue và thêm ví dụ về tarball cục bộ. Hoàn tất khi tài liệu tham khảo giải thích việc tra cứu phiên bản, chọn registry và những gì chế độ offline không thể xác minh.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
JavaScript
Star
10.3k
Fork
5k
Merge trung bình
4 ngày 11 giờ
Pull request đã merge (30 ngày)
26

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của npm/cli

Tất cả issue của npm/cli

Issue tương tự

Thêm issue về JavaScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.