npm / cli

the package manager for JavaScript
https://docs.npmjs.com/cli/
Other
8.44k stars 3.14k forks source link

[BUG] npm 10.9.0 stuck in wsl with ubuntu environment #7868

Open Vincere1st opened 3 days ago

Vincere1st commented 3 days ago

Is there an existing issue for this?

This issue exists in the latest npm version

Current Behavior

I wanted to prepare a project with vue3 under docker with the node:22.10-alpine image in my WSL environment, and when I launched the npm installation, npm stuck for 7mn.

I specify the wsl environment, because I have a vagrant environment on the same machine, and I don't have the same problem.

So why am I opening the problem here? Because if I use version 10.8.0, the installation packages won't be blocked.

I've made a minimal repo for testing here: https://github.com/Vincere1st/minimal-repo-npm-10.9.0-stuck-in-wsl-environnement

If you can't test, i join the results of logs, one with npm 10.8.0 and the other for 10.9.0. npm-10.8.0-logs.txt npm-10.9.0-logs.txt

Here the time for the installation of this minimal repo with 10.8.0 version:

image

And with 10.9.0 image

Expected Behavior

npm install will not stuck with the latest version in wsl environment.

Steps To Reproduce

  1. In wsl with docker
  2. use my minimal repo here: https://github.com/Vincere1st/minimal-repo-npm-10.9.0-stuck-in-wsl-environnement
  3. Follow the readme
  4. The logs will be show in the terminal

Environment

_auth = (protected) access = null all = false allow-same-version = false also = null audit = true audit-level = null auth-type = "web" before = null bin-links = true browser = null ca = null cache = "/root/.npm" cache-max = null cache-min = 0 cafile = null call = "" cert = null cidr = null color = true commit-hooks = true cpu = null 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 expect-result-count = null expect-results = null 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 = "/home/node/.npm-global/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" install-links = false install-strategy = "hoisted" json = false key = null legacy-bundling = false legacy-peer-deps = false libc = null link = false local-address = null location = "user" lockfile-version = null loglevel = "notice" logs-dir = null logs-max = 10 ; long = false ; overridden by cli maxsockets = 15 message = "%s" node-options = null noproxy = [""] npm-version = "10.9.0" offline = false omit = [] omit-lockfile-registry-resolved = false only = null optional = null os = null otp = null pack-destination = "." package = [] package-lock = true package-lock-only = false parseable = false prefer-dedupe = false prefer-offline = false prefer-online = false ; prefix = "/usr/local" ; overridden by env preid = "" production = null progress = true provenance = false provenance-file = null proxy = null read-only = false rebuild-bundle = true registry = "https://registry.npmjs.org/" replace-registry-host = "npmjs" save = true save-bundle = false save-dev = false save-exact = false save-optional = false save-peer = false save-prefix = "^" save-prod = false sbom-format = null sbom-type = "library" scope = "" script-shell = null searchexclude = "" searchlimit = 20 searchopts = "" searchstaleness = 900 shell = "sh" shrinkwrap = true sign-git-commit = false sign-git-tag = false strict-peer-deps = false strict-ssl = true tag = "latest" tag-version-prefix = "v" timing = false 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 workspaces-update = true yes = null

; "env" config from environment

prefix = "/home/node/.npm-global"

; "cli" config from command line options

long = true

jeremyVignelles commented 3 days ago

Could reproduce locally (wsl debian and his repo, that I simplified here) and had the same error here:

FetchError: request to https://registry.npmjs.org/-/npm/v1/security/audits/quick failed, reason: write EPIPE

The issue doesn't seem to happen when docker is running in a VM (ubuntu) instead of WSL...

EDIT: passing --no-audit hides the error, but the install still freezes.

jonesbusy commented 2 days ago

Exact same issue here on Ubuntu 24.04 WSL2 and npm 10.9.0

Vincere1st commented 2 days ago

Hi @jonesbusy , do you run npm inside a docker container or directly inside wsl2 ? Because i haven't try in wsl2 directly.

jonesbusy commented 2 days ago

Directly on WSL. Simple npm i hang.

I never faced such issue with Node 18 or 20 on WSL2

hang

I don't see anything particular on logs

404 silly placeDep ROOT @jridgewell/sourcemap-codec@1.5.0 OK for: magic-string@0.30.12 want: ^1.5.0

Some minutes after

405 silly reify moves {}
406 silly audit bulk request {
jonesbusy commented 2 days ago

EDIT: Well in fact didn't hang. Took 7 minutes

added 30 packages in 7m

4 packages are looking for funding
  run `npm fund` for details
483 silly audit bulk request failed undefined
484 verbose audit error FetchError: request to https://registry.npmjs.org/-/npm/v1/security/audits/quick failed, reason: write EPIPE
484 verbose audit error     at ClientRequest.<anonymous> (/home/vald/.nvm/versions/node/v22.10.0/lib/node_modules/npm/node_modules/minipass-fetch/lib/index.js:130:14)
484 verbose audit error     at ClientRequest.emit (node:events:518:28)
484 verbose audit error     at emitErrorEvent (node:_http_client:103:11)
484 verbose audit error     at TLSSocket.socketErrorListener (node:_http_client:506:5)
484 verbose audit error     at TLSSocket.emit (node:events:518:28)
484 verbose audit error     at emitErrorNT (node:internal/streams/destroy:170:8)
484 verbose audit error     at emitErrorCloseNT (node:internal/streams/destroy:129:3)
484 verbose audit error     at process.processTicksAndRejections (node:internal/process/task_queues:90:21) {
484 verbose audit error   code: 'EPIPE',
484 verbose audit error   errno: 'EPIPE',
484 verbose audit error   syscall: 'write',
484 verbose audit error   type: 'system'
.....

590 verbose os Linux 5.15.133.1-microsoft-standard-WSL2
591 verbose node v22.10.0
592 verbose npm  v10.9.0

Doing the same on node20 is almost instant

node20

milaninfy commented 2 days ago

We have similer issue happening https://github.com/npm/cli/issues/7814 these might be related. which is not specific to WSL but some users are experiencing this, however I am still trying to reproduce the issue concretely where it hangs every time, once we able to reproduce they we can hunt for root cause.

melodyarcjason commented 9 hours ago

Confirming that I am encountering this same hang/freeze and general slowness after updating to npm 10.9.0.

Running WSL2 w/ Ubuntu 22.04.3 LTS Node 20.18

Fairly small vite project - nothing crazy. Was really slow on things like 'audit' and 'audit fix' . Very slow (10 mins) to complete npm outdated. Gave up after 15 min waiting on npm update.

Downgraded to npm @10.8.0 - working good now.