问题
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?
回答1:
İf its abaut 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
ornpm install --no-audit
15% faster
ornpm install --prefer-offline --no-audit
15% faster
check this article for details : speeding up npm install
回答2:
If it's still relevant or maybe for other people of interest: For me it helped, deleting the package.lock file and running npm cache clean --force
.
回答3:
Does your employer use a Proxy Auto-Config (PAC) file?
If so, this SO post might help: Using npm behind corporate proxy .pac
回答4:
It might not be your case, but I had issues with a package being hosted at github with the repo url being only with git protocol (port 9418 not usually open on firewall).
Once added that to the firewall I could npm install without issues.
You can view the repository url with:
$ npm view zone.js repository.url
git://github.com/angular/angular.git
回答5:
npm cache clean --force
npm install --force
It works fine.
来源:https://stackoverflow.com/questions/51434006/how-to-fix-timeout-for-packages-on-npm-install