npm gets stuck on fetchMetadata -> network

2019-03-22 18:35发布

My npm is getting stuck a lot, whether its npm install from package.json or individual packages.

Right now, I'm not even able to sudo npm install node-inspector -g

I'm using node 6.2.1, npm 3.9.5 on ubuntu 16.04

npm cache clear didnt help. The installation takes hours or fails.

10条回答
放我归山
2楼-- · 2019-03-22 19:18

Check if there any issues with proxies if you using any. You can try also to set npm's endpoint manually:

npm config set registry="http://registry.npmjs.org"
查看更多
Rolldiameter
3楼-- · 2019-03-22 19:18

For me it was double temp directories in Windows.

Open a command prompt and type:

echo %TEMP%

You should receive path to a single directory. If you receive multiple directories (I received C:\Users\\AppData\Local\Temp;C:\xampp\php) this might be the problem. You can fix it using this command:

SET TEMP="<correct path to temporary directory>"

where <correct path to temporary directory> might be the first path (before semicolon, that means C:\Users\<user>\AppData\Local\Temp in my case).

查看更多
beautiful°
4楼-- · 2019-03-22 19:19

I had this same problem, with several different installs hanging on fetchMetaData, including the install of yarn mentioned above. I am on a Mac and solved it by updating npm as follows:

npm install npm@latest -g

So if you are encountering this issue on Mac, then try updating and see if it solves your problem.

查看更多
Animai°情兽
5楼-- · 2019-03-22 19:25

Having same problem. Fixed it by switching to correct version of node required by the project.

My project needed node >=v4.3 and <=v5.

1) Check node version being used by nvm ls

2) Use nvm use [version] or else install the specific version. if you don't have.

查看更多
霸刀☆藐视天下
6楼-- · 2019-03-22 19:26

There are a lot of different things that can cause this issue.

I had tried a lot of things, including most of the answers posted here, but no luck.

For some weird reason, this was my ISP's issue. It worked fine when I tried on a different ISP.

查看更多
戒情不戒烟
7楼-- · 2019-03-22 19:27

Did you configured a proxy? See if this returns something:

> npm config get https-proxy
> npm config get proxy

If you have values configured there, they might not match correct ones. If you shouldn't be using a proxy, you can delete them:

> npm config delete https-proxy
> npm config delete proxy

Docs: https://docs.npmjs.com/cli/config

查看更多
登录 后发表回答