npm / cli

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

[BUG] npm install always hangs on first attempt #7891

Closed ZachSARAO closed 4 days ago

ZachSARAO commented 3 weeks ago

Is there an existing issue for this?

This issue exists in the latest npm version

Current Behavior

Using v10.9.0 that comes with Node v23.1.0, every npm install stop responding. Then I cancel the install, run npm install again and it works. This is on WSL Ubuntu 24 using nvm. Older versions of NPM seem to work fine.

I doubt that I am the only person experiencing this - if so then I can provide more details.

This is the output

(node:3911) ExperimentalWarning: CommonJS module /.../.nvm/versions/node/v23.1.0/lib/node_modules/npm/node_modules/debug/src/node.js is loading ES Module /.../.nvm/versions/node/v23.1.0/lib/node_modules/npm/node_modules/supports-color/index.js using require().
Support for loading ES Module in require() is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)

Expected Behavior

npm install should work.

Steps To Reproduce

Running npm install <package> or just npm install triggers this.

Environment

npm -v # 10.9.0
node -v # v23.1.0
OS: Ubuntu 24
System Model name: Dell XPS 9530

npm config ls gives me:

$ npm config list
; node bin location = /home/me/.nvm/versions/node/v23.1.0/bin/node
; node version = v23.1.0
; npm local prefix = /home/me/path/to/client
; npm version = 10.9.0
; cwd = /home/me/pat/to/client
; HOME = /home/me
intersect2-0 commented 3 weeks ago

Experiencing same problem today, sometimes need to cancel and restart multiple times. No visible errors. npm install fastify --loglevel verbose First run npm http fetch GET 200 https://registry.npmjs.org/split2 517ms (cache miss) and hangs. Second run npm http fetch GET 200 https://registry.npmjs.org/split2 133ms (cache revalidated) and hangs. Third run successful.

npm verbose os Linux 5.15.153.1-microsoft-standard-WSL2
npm verbose node v22.11.0
npm verbose npm  v10.9.0
kashif-raza2019 commented 3 weeks ago

I have been experiencing this same issue from quite a while intermittently, thought this might be network related issue but suddenly from past 4 hours now, it is giving me Exit handler error

npm ERR! Exit handler never called!

npm ERR! This is an error with npm itself. Please report this error at:
npm ERR!     <https://github.com/npm/cli/issues>

npm ERR! A complete log of this run can be found in: C:\Users\KASHIF RAZA\AppData\Local\npm-cache\_logs\2024-11-04T20_56_16_502Z-debug-0.log

Aborting installation.
  npm install has failed.

I have tried downgrading npm version to v9.9.3 but still no resolution. Node version: v22.5.0

stefanos82 commented 2 weeks ago

I have the same issue with both v20.18.0 and v22.11.0.

If we add --verbose at the end of npm install, we can clearly see it's an issue with caching revalidation by registry.npmjs.org; it hangs forever, unless you interrupt it and re-execute the command.

BitPatty commented 2 weeks ago

Same issue with npm 10.9.0 on node 22.11.0.

Workaround

Installing with --force appears to work consistently (further reinforcing the cache suspicion):

npm install --force
mrdobalina2k commented 2 weeks ago

I had the same issue. Using --force on npm install solved it.

Tofandel commented 2 weeks ago

This is a duplicate of https://github.com/npm/cli/issues/4028

npm install --force works because it bypasses checkPlatform checks, it's not a cache issue

You should downgrade to npm 10.3.0

wraithgar commented 4 days ago

This was fixed in npm 10.9.1 (via https://github.com/npm/npm-install-checks/pull/120)