cli icon indicating copy to clipboard operation
cli copied to clipboard

[BUG] NPM doesn't allow me to 'npm i' on even slightly weak network connections

Open okirpane opened this issue 3 years ago • 2 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

This issue exists in the latest npm version

  • [X] I am using the latest npm

Current Behavior

When I run npm i on my computer (Macbook Pro 2020) with a 5G internet connection that drops packages every now and then, the command hangs at larger packages. Basically:

  • I run npm i
  • It downloads a few packages
  • It reaches a package that is slightly big
  • Then just... stops.
  • I have to then CTRL+C in the terminal to quit the process and find a more consistent network connection.

Expected Behavior

I would expect my package manager to at least work when my connection wavers a little. The fact that NPM just fails completely is dissapointing.

Steps To Reproduce

  1. Connect to a slightly unstable network connection
  2. Start a project with some node_modules
  3. Run npm i
  4. Observe that it hangs when it reaches a large package.

Environment

  • npm: npm 8.3.0
  • Node.js: Node.js v16.11.0
  • OS Name: MacOS Monterey 12.2.1
  • System Model Name: Macbook Pro 2020
  • npm config:
; "builtin" config from /opt/homebrew/lib/node_modules/npm/npmrc

prefix = "/opt/homebrew" 

; "project" config from /Users/okirp/Desktop/ojasvin/.npmrc

engine-strict = true 

; node bin location = /opt/homebrew/Cellar/node/16.11.0/bin/node
; cwd = /Users/okirp/Desktop/ojasvin
; HOME = /Users/okirp
; Run `npm config ls -l` to show all defaults.

okirpane avatar Feb 17 '22 11:02 okirpane

it's likely what's happening here is a request is timing out, so we're retrying it. by default we'll retry the same package 2 times after the initial failure, so i would expect to see what appears to be npm hanging for the time it takes 3 requests to timeout which is ~15 minutes by default. if you npm i --fetch-timeout=60000 it'll reduce the overall failure time to ~3 minutes, though based on the information provided all that's really going to do is get you to an error quicker.

i'm curious, how large of a package are you seeing this failure with? if you download the package tarball outside of npm (i.e. curl or wget) how long does it take to transfer?

nlf avatar Mar 07 '22 22:03 nlf

this is extremely annoying. Happened to me in train again yesterday 2 retries as default is not enough. Sometimes you're offline on train for 5 minutes or more The default retries should be like 10 or so Also, large packages should be fetched in chunks and the chunks should be retried individually

spotlesscoder avatar Jun 06 '24 07:06 spotlesscoder

Closing: this looks to be similar if not a duplicate of an existing issue, #7585. If you believe your instance is unique, please provide further clarifying details.

kchindam-infy avatar Jun 26 '25 16:06 kchindam-infy