[BUG] `npm install --offline` still sends requests to the registry: the update check asks it for npm

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

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

@charan-rathore がすでに取り組んでいます。

2026年11月27日 から。

  • #10374 @charan-rathore による — オープン

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
javascript, nodejs
領域
cli, devtools

調査の方向性

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.

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

説明

Bug Needs Triage
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
  1. Fetch repro.mjs at the revision I ran (curl.exe in Windows PowerShell, where curl is Invoke-WebRequest):

    curl -LO https://gist.githubusercontent.com/YevheniiKotyrlo/dd5c4d6396fab15692dd8ddd63399fc9/raw/db427f58e0f3de73e67f587037df0139f6ab8a34/repro.mjs
    
  2. Run it with a Node that npm 12 runs on:

    node repro.mjs
    

    With 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, and node 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:26 image
  • 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"
主要言語
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 を短くまとめたダイジェスト。