npm / npm/cli

[BUG] ENETUNREACH errors during npm install -> dep from github

Open
#4,167 6 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Needs Triage Release 8.x
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

👋 I have this bug inside our CI with http_proxy set it's impossible to have npm to work. It seems it's not able to handle the proxy anymore (upgrade/change of the lib doing requests?)

npm ci does not work.

$ npm --version
8.3.0
$ npm ci --no-audit
npm ERR! code 1
npm ERR! git dep preparation failed
npm ERR! command /usr/bin/node /usr/lib/node_modules/npm/bin/npm-cli.js install --force --cache=/root/.npm --prefer-offline=false --prefer-online=false --offline=false --no-progress --no-save --no-audit --include=dev --include=peer --include=optional --no-package-lock-only --no-dry-run
npm ERR! npm WARN using --force Recommended protections disabled.
npm ERR! npm ERR! code 1
npm ERR! npm ERR! path /root/.npm/_cacache/tmp/git-clonezsHhpF/node_modules/tree-sitter-cli
npm ERR! npm ERR! command failed
npm ERR! npm ERR! command sh -c node install.js
npm ERR! npm ERR! Downloading https://github.com/tree-sitter/tree-sitter/releases/download/v0.20.0/tree-sitter-linux-x64.gz
npm ERR! npm ERR! node:events:368
npm ERR! npm ERR!       throw er; // Unhandled 'error' event
npm ERR! npm ERR!       ^
npm ERR! npm ERR! 
npm ERR! npm ERR! Error: connect ENETUNREACH 140.82.113.4:443
npm ERR! npm ERR!     at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1161:16)
npm ERR! npm ERR! Emitted 'error' event on ClientRequest instance at:
npm ERR! npm ERR!     at TLSSocket.socketErrorListener (node:_http_client:447:9)
npm ERR! npm ERR!     at TLSSocket.emit (node:events:390:28)
npm ERR! npm ERR!     at emitErrorNT (node:internal/streams/destroy:157:8)
npm ERR! npm ERR!     at emitErrorCloseNT (node:internal/streams/destroy:122:3)
npm ERR! npm ERR!     at processTicksAndRejections (node:internal/process/task_queues:83:21) {
npm ERR! npm ERR!   errno: -101,
npm ERR! npm ERR!   code: 'ENETUNREACH',
npm ERR! npm ERR!   syscall: 'connect',
npm ERR! npm ERR!   address: '140.82.113.4',
npm ERR! npm ERR!   port: 443
npm ERR! npm ERR! }
npm ERR! 
npm ERR! npm ERR! A complete log of this run can be found in:
npm ERR! npm ERR!     /root/.npm/_logs/2021-12-13T14_41_06_064Z-debug-0.log
npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2021-12-13T14_40_34_553Z-debug-0.log

It's a major regression.

Expected Behavior

npm ci ✔️ as it does with npm@6 for the same version of Node.

Steps To Reproduce

ℹ️ we're inside a CI with http_proxy and https_proxy
If we read the doc, it should be fine https://docs.npmjs.com/cli/v8/using-npm/config#https-proxy

  1. Install npm 6
  2. Use the package.json + rename lock6.json to package-lock.json
  3. Run npm ci
  4. It works

  1. Install npm 8
  2. Use the package.json + rename lock6.json to package-lock.json or take the pacakge-lock.json
  3. Run npm ci
  4. It breaks

Demo repo https://github.com/dhoko/bug-npm with with 3 files:

  • package.json
  • package-lock.json (made with npm 8)
  • lock6.json (lockfile made with npm 6)

I found this issue https://github.com/npm/cli/issues/2983 which seems similar as the issue comes with what's after npm 6.

Thx 🙏

Environment
  • npm: 8.3.0
  • Node: 16.11.1
  • OS: debian stable
  • platform: CI
  • npm config:
$ npm config ls
; node bin location = /usr/bin/node
; cwd = /builds/xxx/find-app-dependencies
; HOME = /root
; Run `npm config ls -l` to show all defaults.
$ npm config ls -l
; "default" config from default values
_auth = (protected) 
access = null 
all = false 
allow-same-version = false 
also = null 
audit = true 
audit-level = null 
auth-type = "legacy" 
before = null 
bin-links = true 
browser = null 
ca = null 
cache = "/root/.npm" 
cache-max = null 
cache-min = 0 
cafile = null 
call = "" 
cert = null 
ci-name = "gitlab" 
cidr = null 
color = true 
commit-hooks = true 
depth = null 
description = true 
dev = false 
diff = [] 
diff-dst-prefix = "b/" 
diff-ignore-all-space = false 
diff-name-only = false 
diff-no-prefix = false 
diff-src-prefix = "a/" 
diff-text = false 
diff-unified = 3 
dry-run = false 
editor = "vi" 
engine-strict = false 
fetch-retries = 2 
fetch-retry-factor = 10 
fetch-retry-maxtimeout = 60000 
fetch-retry-mintimeout = 10000 
fetch-timeout = 300000 
force = false 
foreground-scripts = false 
format-package-lock = true 
fund = true 
git = "git" 
git-tag-version = true 
global = false 
global-style = false 
globalconfig = "/usr/etc/npmrc" 
heading = "npm" 
https-proxy = null 
if-present = false 
ignore-scripts = false 
include = [] 
include-staged = false 
include-workspace-root = false 
init-author-email = "" 
init-author-name = "" 
init-author-url = "" 
init-license = "ISC" 
init-module = "/root/.npm-init.js" 
init-version = "1.0.0" 
init.author.email = "" 
init.author.name = "" 
init.author.url = "" 
init.license = "ISC" 
init.module = "/root/.npm-init.js" 
init.version = "1.0.0" 
json = false 
key = null 
legacy-bundling = false 
legacy-peer-deps = false 
link = false 
local-address = null 
location = "user" 
lockfile-version = null 
loglevel = "notice" 
logs-max = 10 
; long = false ; overridden by cli
maxsockets = 15 
message = "%s" 
metrics-registry = "https://registry.npmjs.org/" 
node-options = null 
node-version = "v16.13.0" 
noproxy = [""] 
npm-version = "8.1.0" 
offline = false 
omit = [] 
only = null 
optional = null 
otp = null 
pack-destination = "." 
package = [] 
package-lock = true 
package-lock-only = false 
parseable = false 
prefer-offline = false 
prefer-online = false 
prefix = "/usr" 
preid = "" 
production = null 
progress = false 
proxy = null 
read-only = false 
rebuild-bundle = true 
registry = "https://registry.npmjs.org/" 
save = true 
save-bundle = false 
save-dev = false 
save-exact = false 
save-optional = false 
save-peer = false 
save-prefix = "^" 
save-prod = false 
scope = "" 
script-shell = null 
searchexclude = "" 
searchlimit = 20 
searchopts = "" 
searchstaleness = 900 
shell = "sh" 
shrinkwrap = true 
sign-git-commit = false 
sign-git-tag = false 
sso-poll-frequency = 500 
sso-type = "oauth" 
strict-peer-deps = false 
strict-ssl = true 
tag = "latest" 
tag-version-prefix = "v" 
timing = false 
tmp = "/tmp" 
umask = 0 
unicode = false 
update-notifier = true 
usage = false 
user-agent = "npm/{npm-version} node/{node-version} {platform} {arch} workspaces/{workspaces} {ci}" 
userconfig = "/root/.npmrc" 
version = false 
versions = false 
viewer = "man" 
which = null 
workspace = [] 
workspaces = null 
yes = null 
; "cli" config from command line options
long = true

yes inside node and npm are not the same, because I tested severals version before making the issue. Only way to fix this issue is to rollback to npm@6

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

Start by reproducing the failure with the linked demo repo, npm 8.3.0, Node 16.11.1, and http_proxy/https_proxy set; compare npm 8 with npm 6 during npm ci and git dependency preparation. Trace the proxy configuration used for the tree-sitter download. Done means npm ci completes through the proxy on npm 8 without ENETUNREACH.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, javascript, nodejs
Domain
cli, networking, tooling
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.