Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix timeout for packages on `npm install`?

When I run npm install it seems to work fine until part way installing packages. It seems to have no problem with the first half, but then after a while it will fail to be able to reach other packages. I just get the repeating errors, eg:

npm http request GET https://registry.npmjs.org/react-hot-loader
npm info attempt registry request try #3 at 6:43:34 AM
npm http request GET https://registry.npmjs.org/react-tap-event-plugin
npm info attempt registry request try #3 at 6:43:34 AM
npm http request GET https://registry.npmjs.org/react-test-renderer

etc.

It will continue to do this for an hour and and then the install will fail.

The install breaks at a different package each time so I don't think it's a problem with a particular file.

I can access these files fine with my browser and curl.

My work has a firewall but this domain is whitelisted.

Would anyone know what I could do to get this to work or what could be causing it?

like image 224
MeltingDog Avatar asked Jul 20 '18 01:07

MeltingDog


People also ask

How do I fix npm timeout errors on slow Internet connections?

How To Fix NPM Timeout Errors On Slow Internet Connections. The default value is 10 seconds, change it to 3600 seconds (1 hour) or more. npm config set cache-min 3600. Finally, run this command to check whether all the configuration changes are successfully applied or not.

How do I force an npm package to install?

Run npm update -g npm. Execute this command by running the command prompt as Administrator npm install -g windows-build-tools. Run npm install inside the project folder where the package. json file is located, if it doesn't work run: npm install --force.


2 Answers

If it's about the timing problem you should find a speed solutions for npm install.

So you can try these faster command than npm install :

pnpm install %70 faster
or
npm install --no-audit 15% faster
or
npm install --prefer-offline --no-audit 15% faster

check this article for details : speeding up npm install

like image 62
Ömür Alçin Avatar answered Sep 17 '22 14:09

Ömür Alçin


You can override the max and min timeout in ~/.npmrc.

// npm config ls -l
// add these 2 lines in ~/.npmrc
fetch-retry-maxtimeout = 6000000
fetch-retry-mintimeout = 1000000
like image 29
Siddharth Avatar answered Sep 17 '22 14:09

Siddharth