[BUG] `npm install --offline` still sends requests to the registry: the update check asks it for npm
Maintainer thường phản hồi trong vòng 2 ngày
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 35/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
Hướng nghiên cứu
The update check lives in lib/cli/update-notifier.js, which fetches the manifest with cache: false and skips only on update-notifier off, global updates and CI, so offline is not honoured. Read that file alongside node_modules/npm-registry-fetch/lib/index.js to see how the offline setting reaches the fetch. Done means npm install --offline sends no request to the registry (or only cache reads), while online behaviour is unchanged; note that pull request #10374 is already open against this issue.
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 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 --offline, npm still sends requests to the registry. npm install --offline in a project with no dependencies and a new cache sends GET /npm to the registry: the update check asking for the latest npm. offline is described as "Force offline mode: no network requests will be done during install."
The check fetches the manifest with cache: false, and with no cache path the fetch goes to the network whatever offline sets. Its skip conditions are update-notifier being off, a global npm update and CI; offline is not among them.
npm 10.2.4 sends nothing with the same steps; 10.2.5, 11.20.0 and 12.2.3 each send it. My reproducer's registry answers 404, after which pacote asks again for the full packument, so its output below shows GET /npm twice. cache: false came with #7061, in 10.2.5.
Expected Behavior
With offline set, nothing reaches the registry: no update check, or one answered from the cache only. Without offline, the update check runs as it does now.
Steps To Reproduce
-
Fetch repro.mjs at the revision I ran (
curl.exein Windows PowerShell, wherecurlisInvoke-WebRequest):curl -LO https://gist.githubusercontent.com/YevheniiKotyrlo/dd5c4d6396fab15692dd8ddd63399fc9/raw/db427f58e0f3de73e67f587037df0139f6ab8a34/repro.mjs -
Run it with a Node that npm 12 runs on:
node repro.mjsWith no argument it installs the latest npm below its temporary folder, with the npm that comes with Node;
node repro.mjs <version>installs that version, andnode repro.mjs <path to bin/npm-cli.js>runs a checkout.
It starts a registry stand-in on 127.0.0.1 that answers 404 to every request and counts each connection and request, makes a project whose package.json has only a name and a version, and runs npm install --offline --registry=<the stand-in> there with a new cache, empty user and global config files, none of the caller's npm_config_* variables, and none of the variables the ci-info that npm loads reads to tell CI. Once npm and every process holding its output have ended, it reports what reached the stand-in. It exits 1 when anything did, 0 when nothing did, and 2 when it cannot tell, as when a step fails, npm install --offline among them.
On Windows 11 with npm 12.2.3:
node v26.12.1 on win32 x64
# with the npm that comes with node, in <tmp>\npm-install
$ npm install npm@latest
installed: <tmp>\npm-install\node_modules\npm\bin\npm-cli.js
# ci-info 4.4.0, which npm loads, tells CI by 60 variables; npm gets none of them
$ npm --version
12.2.3
# a stand-in registry at http://127.0.0.1:60724/ answers 404 to every request
# in <tmp>\project: a package.json with a name and a version, and no dependencies; npm's cache: <tmp>\npm-cache, new
$ npm install --offline --registry=http://127.0.0.1:60724/
up to date, audited 1 package in 4s
found 0 vulnerabilities
exit 0
# what reached the stand-in registry: 1 connection, 2 requests
connection 1: GET /npm
connection 1: GET /npm
RESULT (exit 1): defect shows (npm 12.2.3): npm install --offline exited 0, and 1 connection and 2 requests reached the registry: GET /npm, GET /npm
The latest branch at 787f1520, run from a clone, ends the same way, and so do 12.2.3 and that branch on Linux, in Docker's node:26 image. With npm 10.2.4 it ends:
RESULT (exit 0): defect does not show (npm 10.2.4): npm install --offline exited 0, and nothing reached the registry
Environment
- npm: 12.2.3
- Node.js: 26.12.1 on Windows, 26.13.1 on Linux
- OS Name: Windows 11 Pro 10.0.26300; Debian, in Docker's
node:26image - System Model Name: a desktop PC
- npm config:
; the reproducer runs npm with empty user and global config files, these through the environment, and --offline and --registry on the command line
cache = "<tmp>\npm-cache"
color = false
noproxy = "127.0.0.1"
- 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
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của npm/cli
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 2 ngày
-
[BUG] scripts/dependency-graph.js splits npm-cli-repos.txt on os.EOL, so DEPENDENCIES.md depends on the checkout's line endingsCó thể đã có người làm @saruk-vedant đã nhận 7 ngày trước. Đang mởBug Needs Triage Triage Requested
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 2 ngày
-
[BUG] npm pkg delete removes the first array item for a nonexistent propertyCó thể đã có người làm @drawliin đã nhận 42 ngày trước. Đang mởcmd:delete Priority 3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
Maintainer thường phản hồi trong vòng 2 ngày
-
create node pr: Node.js 20 deprecation & `DEP0040` warnings loggedCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mởEngineering Priority 1
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 80/100
Maintainer thường phản hồi trong vòng 2 ngày
-
`npm audit signatures` does not report how many packages it skipped for want of registry keysCó thể đã có người làm @greenlincoln05 đã nhận 63 ngày trước. Đang mởPriority 3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 2 ngày
Issue tương tự
-
docs: add SECURITY.md vulnerability reporting policyCó thể đã có người làm @AK-Lmn đã nhận hôm nay. Đang mở
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 72/100
flisk-sh/linux2wasm#12 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
possible bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Mintplex-Labs/anything-llm#7388 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 60/100
Maintainer thường phản hồi trong vòng 1 ngày
-
v6: Minified bootstrap.min.css is missing header infoCó thể đã có người làm @lazerg đã nhận hôm nay. Đang mởbug build confirmed has-pr v6
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[workshop-sync] workshop/side-quest-26-01-forecast-costs.md: forecast default history window is inaccurateCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởdocumentation
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
githubnext/gh-aw-workshop#6332 ·
Maintainer thường phản hồi trong vòng 1 ngày