[BUG] npx <pkg>@<exact version> loads Arborist and asks the registry when the npx cache already has it

Đang mở
#10,324 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

@azchohfi đang làm issue này rồi.

Từ ngày 21/11/2026.

  • #10325 của @azchohfi — đang mở

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
45/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
javascript, nodejs
Lĩnh vực
cli, performance

Hướng nghiên cứu

Start in lib/commands/exec.js and the libnpmexec entry point where getManifest is called with preferOnline, and trace how a manifest is resolved for a spec already in the npx cache. Also read lib/commands/init.js and the update-workspaces call it makes. Reproduce with npx --yes [email protected] --loglevel http on a warm cache and count loaded modules via NODE_OPTIONS; done means a pinned cached spec runs the bin with no packument request and a much lower module count, while ranges and tags keep the current path.

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

Mô tả

Bug Priority 3 Triage Requested ws:arborist
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

npx [email protected] my-app --template react with create-vite 9.2.1 already in the npx cache still loads 543 modules and revalidates the packument before it runs the bin. Arborist and pacote are required at the top of libnpmexec, and getManifest uses preferOnline. npm create also loads Arborist through update-workspaces in lib/commands/init.js.

Expected Behavior

For a registry spec pinned to an exact version that's already in the npx cache dir, and isn't in the local tree or global prefix, the bin can run straight from the cache. With that and lazy requires it's 142 modules for npx and 150 for npm create, with no network. Ranges, tags and anything not cached take the current path. With a warm cache, across two runs, npx gets 1.8x faster on Windows (about 0.7 s saved) and 2.6-2.8x faster on Linux. npm create is 1.75x faster on both.

Steps To Reproduce
  1. Run npx --yes [email protected] my-app --template react once so create-vite 9.2.1 is in the npx cache.
  2. Run it again with --loglevel http, or with NODE_OPTIONS requiring a script that prints Object.keys(require.cache).length on exit.
  3. npm still fetches the create-vite packument and loads 543 modules (565 on 12.2.3) before it runs the cached bin. Same for npm create [email protected] my-app -- --template react.
Environment
  • npm: 11.19.0 for the timings above. 12.2.3 behaves the same (same registry request, 565 modules).
  • Node.js: 26.7.0
  • OS Name: Windows 11 (x64) and Linux (WSL2, ext4) on the same machine
  • System Model Name: desktop, Intel Core i9-10900K
  • npm config:
; defaults, with a warm cache
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.