npm / npm/cli

[BUG] `npm link` tries accessing the network

Open
#8,511 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Documentation Priority 2
Dominant language
JavaScript
Stars
10.1k
Forks
4.7k
Avg merge
2d 2h
Merged PRs (30d)
19

Description

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
Current Behavior

It prints a network related error:

npm error code EAI_AGAIN
npm error syscall getaddrinfo
npm error errno EAI_AGAIN
npm error request to https://registry.npmjs.org/react-dom failed, reason: getaddrinfo EAI_AGAIN registry.npmjs.org
npm error A complete log of this run can be found in: /root/.npm/_logs/2025-08-15T13_42_32_900Z-debug-0.log
Expected Behavior

Any error that is not network-related (e.g. because there's no packages.json) or success.

Steps To Reproduce

npm link is documented to only create a symlink, but instead it downloads stuff.

This might be a huge issue globally, because npm commands are often called in CI, and it is usually assumed that by the time npm link is called CI has all the deps cached (otherwise every pipeline someone somewhere triggers would result in accessing nodejs servers without devopses knowing it).

So unfortunately, npm link exhibits undocumented behavior where if it doesn't find deps in the system, it goes out online and silently fetches stuff from the internet, which puts excess load on both the users of CI and the nodejs servers.

To reproduce (in terms of terminal commands):

$ mkdir -p /tmp/foo && cd /tmp/foo
$ echo 'FROM docker.io/library/fedora:41\nRUN dnf install -y npm sqlite3' > Dockerfile
$ podman build -f Dockerfile -t test
[…build output snipped…]
$ podman run --rm --net=none test npm link react-dom
npm error code EAI_AGAIN
npm error syscall getaddrinfo
npm error errno EAI_AGAIN
npm error request to https://registry.npmjs.org/react-dom failed, reason: getaddrinfo EAI_AGAIN registry.npmjs.org
npm error A complete log of this run can be found in: /root/.npm/_logs/2025-08-15T13_42_32_900Z-debug-0.log
Environment
  • npm: 11.5.2
  • Node.js: v24.5.0
  • OS Name: Archlinux
  • System Model Name: Dell G15
  • npm config:
; node bin location = /usr/bin/node
; node version = v24.5.0
; npm local prefix = /tmp/foo
; npm version = 11.5.2
; cwd = /tmp/foo
; HOME = /home/constantine
; Run `npm config ls -l` to show all defaults.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the report with the shown Dockerfile and podman run --rm --net=none test npm link react-dom command. No source file or test is named, so first locate the npm link entry point and add a regression test; done means the command creates the symlink or reports a non-network error without contacting the registry.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
cli, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.