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

Abierto
#10,371 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

@charan-rathore ya está trabajando en esto.

Desde el 27/11/2026.

  • #10374 de @charan-rathore — abierto

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
javascript, nodejs
Área
cli, devtools

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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"
Lenguaje dominante
JavaScript
Estrellas
10.3k
Forks
5k
Merge medio
4 d 11 h
PR fusionados (30 d)
26

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de npm/cli

Todos los issues de npm/cli

Issues similares

Más issues de JavaScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.