node.js npm 卡在 fetchMetadata -> 网络上

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/37860219/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 20:18:54  来源:igfitidea点击:

npm gets stuck on fetchMetadata -> network

node.jsnpmnpm-install

提问by Dushyant Bangal

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

我的 npm 卡住了很多,无论是 npm install frompackage.json还是单个包。

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

现在,我什至无法 sudo npm install node-inspector -g

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

我正在使用node 6.2.1npm 3.9.5ubuntu 16.04

npm cache cleardidn't help. The installation takes hours or fails.

npm cache clear没有帮助。安装需要数小时或失败。

回答by Konstantin Azizov

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

如果您使用代理,请检查代理是否有任何问题。您也可以尝试手动设置 npm 的端点:

npm config set registry="http://registry.npmjs.org"

回答by Tomer Ben David

try yarninstaller instead of npm:

尝试使用纱线安装程序代替 npm:

sudo npm install -g yarn
yarn install

I found it much more resilient to such problems.

我发现它对这些问题更有弹性。

回答by danjones_mcr

You'll need to clear your https proxy settings:

您需要清除 https 代理设置:

npm config rm proxy
npm config rm https-proxy

回答by BruceHill

I had this same problem, with several different installs hanging on fetchMetaData, including the install of yarnmentioned above. I am on a Macand solved it by updating npmas follows:

我遇到了同样的问题,有几个不同的安装挂起fetchMetaData,包括yarn上面提到的安装。我在 aMac并通过npm如下更新解决了它:

npm install npm@latest -g

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

因此,如果您在 上遇到此问题Mac,请尝试更新并查看它是否能解决您的问题。

回答by Ogglas

For me it was double temp directories in Windows.

对我来说,它是 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:

您应该收到单个目录的路径。如果您收到多个目录(我收到 C:\Users\\AppData\Local\Temp;C:\xampp\php),这可能是问题所在。您可以使用以下命令修复它:

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\Tempin my case).

哪里<correct path to temporary directory>可能是第一条路径(在分号之前,这意味着C:\Users\<user>\AppData\Local\Temp在我的情况下)。

回答by Paul Melero

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

文档:https: //docs.npmjs.com/cli/config

回答by feeeper

I got the same issue. First of all try to run npm installwith -verboseflag. That can help you identify your problem.

我遇到了同样的问题。首先尝试npm install使用-verbose标志运行。这可以帮助您确定您的问题。

That command told me that I had some problem with tunneling socket:

该命令告诉我,我在使用隧道套接字时遇到了一些问题:

tunneling socket could not be established, cause=write EPROTO 101057795:error:140770FC:SSL routines:SSL 23_GET_SERVER_HELLO:unknown protocol:openssl\ssl\s23_clnt.c:794:

无法建立隧道套接字,cause=write EPROTO 101057795:error:140770FC:SSLroutines:SSL 23_GET_SERVER_HELLO:unknown protocol:openssl\ssl\s23_clnt.c:794:

After that I googled the error and found thread on githubabout that problem. The problem was in proxy: previously I set up HTTP_PROXYenvironment variable and after removing then environment variable npm installcompleted without any error.

之后,我在 google 上搜索了错误并在 github 上找到有关该问题的线程。问题出在代理中:以前我设置了HTTP_PROXY环境变量,然后在删除环境变量后npm install完成,没有任何错误。

回答by Dushyant Bangal

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.

出于某种奇怪的原因,这是我的 ISP 的问题。当我尝试使用不同的 ISP 时,它运行良好。

回答by giridhar

For the major chunk of the people, the issue could be related to proxy settings and can be solved by the above-mentioned solutions.

对于大部分人来说,问题可能与代理设置有关,可以通过上述解决方案解决。

For me, the issue was something else. I have private repository dependencies which are hosted at Bitbucket and are resolved through "git+ssh://[email protected]/" which intern uses SSH to retrieve the repo.

对我来说,问题是另一回事。我有托管在 Bitbucket 的私有存储库依赖项,并通过“git+ssh://[email protected]/”解决,实习生使用 SSH 来检索存储库。

SSH by default prefers IPv6 if DNS retrieves AAAA record and if the host has one. Since Bitbucket does have AAAA record, SSH is done over IPv6. But my ISP doesn't support IPv6 (You could check if your ISP support's IPv6 by taking a test in http://ipv6-test.com/).

如果 DNS 检索 AAAA 记录并且主机有一个,则 SSH 默认首选 IPv6。由于 Bitbucket 确实有 AAAA 记录,SSH 是通过 IPv6 完成的。但是我的 ISP 不支持 IPv6(您可以通过在http://ipv6-test.com/ 中进行测试来检查您的 ISP 是否支持 IPv6 )。

To solve this, you could force SSH client to use IPv4 instead of IPv6.

要解决此问题,您可以强制 SSH 客户端使用 IPv4 而不是 IPv6。

Set AddressFamily inetin /etc/ssh/ssh_configand restart SSH client.

设置AddressFamily inet/etc/ssh/ssh_config并重新启动SSH客户端。

On Ubuntu to restart SSH client use sudo service ssh restart

在Ubuntu上重启SSH客户端使用 sudo service ssh restart

回答by myDoggyWritesCode

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

有同样的问题。通过切换到项目所需的正确节点版本来修复它。

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

我的项目需要节点 >=v4.3 and <=v5.

1) Check node version being used by nvm ls

1)检查正在使用的节点版本 nvm ls

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

2) 使用nvm use [version]或安装特定版本。如果你没有。