简体   繁体   English

npm 卡在 fetchMetadata -> 网络上

[英]npm gets stuck on fetchMetadata -> network

My npm is getting stuck a lot, whether its npm install from package.json or individual packages.我的 npm 卡住了很多,无论是从package.json安装 npm 还是单个包。

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.5 on ubuntu 16.04我在ubuntu 16.04上使用node 6.2.1npm 3.9.5

npm cache clear didn't help. npm cache clear没有帮助。 The installation takes hours or fails.安装需要数小时或失败。

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"

try yarn installer instead of npm:尝试使用纱线安装程序代替 npm:

sudo npm install -g yarn
yarn install

I found it much more resilient to such problems.我发现它对这些问题更有弹性。

You'll need to clear your https proxy settings:您需要清除 https 代理设置:

npm config rm proxy
npm config rm https-proxy

I had this same problem, with several different installs hanging on fetchMetaData , including the install of yarn mentioned above.我遇到了同样的问题,在fetchMetaData上挂了几个不同的安装,包括上面提到的yarn的安装。 I am on a Mac and solved it by updating npm as follows:我在Mac ,通过如下更新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上遇到此问题,请尝试更新并查看它是否能解决您的问题。

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

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.如果您收到多个目录(我收到 C:\\Users\\\\AppData\\Local\\Temp;C:\\xampp\\php),这可能是问题所在。 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).其中<correct path to temporary directory>可能是第一个路径(在分号之前,这意味着C:\\Users\\<user>\\AppData\\Local\\Temp在我的情况下)。

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.出于某种奇怪的原因,这是我的 ISP 的问题。 It worked fine when I tried on a different ISP.当我尝试使用不同的 ISP 时,它运行良好。

I got the same issue.我遇到了同样的问题。 First of all try to run npm install with -verbose flag.首先尝试使用-verbose标志运行npm install That can help you identify your problem.这可以帮助您确定您的问题。

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 github about that problem.之后,我在 google 上搜索了错误并在 github 上找到有关该问题的线程 The problem was in proxy: previously I set up HTTP_PROXY environment variable and after removing then environment variable npm install completed without any error.问题出在代理中:以前我设置了HTTP_PROXY环境变量,然后在删除环境变量之后npm install完成,没有任何错误。

I had a similar issue to @giridhar but it wasn't related to the proxy, just that my ssh key wasn't setup properly.我有一个与@giridhar 类似的问题,但它与代理无关,只是我的 ssh 密钥设置不正确。 When trying to do a git ls-remote from an ssh:// url.尝试从 ssh:// url 执行 git ls-remote 时。 I was getting the prompt to enter my passphrase for my ssh key.我收到了为我的 ssh 密钥输入密码的提示。

I had to run these commands on command line in order to stop getting asked for my pass phrase:我必须在命令行上运行这些命令才能停止询问我的密码:

$ eval `ssh-agent -s`
$ ssh-add ~/.ssh/id_rsa

Once you enter your pass phrase, then you don't have to enter it again anymore.输入密码短语后,您就不必再输入它了。

I highly recommend reading this wiki from Atlassian if you need to setup an ssh key: https://confluence.atlassian.com/bitbucket/set-up-an-ssh-key-728138079.html如果您需要设置 ssh 密钥,我强烈建议您从 Atlassian 阅读此 wiki: https : //confluence.atlassian.com/bitbucket/set-up-an-ssh-key-728138079.html

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://git@bitbucket.org/" which intern uses SSH to retrieve the repo.我有托管在 Bitbucket 的私有存储库依赖项,并通过“git+ssh://git@bitbucket.org/”解决,实习生使用 SSH 来检索存储库。

SSH by default prefers IPv6 if DNS retrieves AAAA record and if the host has one.如果 DNS 检索 AAAA 记录并且主机有一个,则 SSH 默认首选 IPv6。 Since Bitbucket does have AAAA record, SSH is done over IPv6.由于 Bitbucket 确实有 AAAA 记录,SSH 是通过 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/ ).但是我的 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 inet in /etc/ssh/ssh_config and restart SSH client./etc/ssh/ssh_config设置AddressFamily inet并重新启动 SSH 客户端。

On Ubuntu to restart SSH client use sudo service ssh restart在 Ubuntu 上重启 SSH 客户端使用sudo service ssh restart

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. 2) 使用nvm use [version]或者安装特定版本。 if you don't have.如果你没有。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM