node.js npm install 卡在 fetchMetadata

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/45433130/
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 18:23:38  来源:igfitidea点击:

npm install gets stuck at fetchMetadata

node.jsnpm

提问by dschu

I'm currently unable to run npm installin any project since today. I'm running node v8.2.1 & npm 5.3.0 (installed via nvm).

npm install从今天起,我目前无法在任何项目中运行。我正在运行 node v8.2.1 & npm 5.3.0(通过 nvm 安装)。

When typing npm installit gets stuck on fetchMetadataeverytime: ? ????????????????? ? fetchMetadata: sill pacote range manifest for longest@^1.0.1 fetched in 197ms

每次输入npm install时都会卡住fetchMetadata? ????????????????? ? fetchMetadata: sill pacote range manifest for longest@^1.0.1 fetched in 197ms

I've tried switching back to npm 5.0.3which worked flawless, but still get stuck.

我试过切换回npm 5.0.3完美无缺的工作,但仍然卡住了。

Details to my computer:MacBook Pro running macOS 10.12.6

我的电脑的详细信息:正在运行的 MacBook PromacOS 10.12.6

回答by Andru

As a first thing, run npm install --verboseto see more!

首先,跑去npm install --verbose看更多!

What happened in my case:

在我的情况下发生了什么:

In your package.jsonsearch for packages you directly get from Github. In my case such a package did not exist anymore. Such lines look like

在您package.json搜索软件包时,您可以直接从 Github 获得。在我的情况下,这样的包不再存在。这样的线条看起来像

"NAME_OF_PACKAGE": "git+ssh://[email protected]/SOME_USER/NAME_OF_PACKAGE.git",

Remove the package, fix the name/location or change to the npm version of the package.

删除包,修复名称/位置或更改为包的 npm 版本。



Further note: I got several other similar errors, all the same but the package name was different from longest@^1.0.1. I also had p-try@somethingor array-ify@something

进一步说明:我遇到了其他几个类似的错误,都一样,但包名与longest@^1.0.1. 我也有p-try@somethingarray-ify@something



For me all that didn't work: rm -rf ~/.npm, npm cache cleanor rm package-lock.jsonall didn't work!

对我来说,所有这些都没有用:rm -rf ~/.npmnpm cache clean或者rm package-lock.json都没有用

回答by CptUnlucky

The question is quite old but I've fallen into this scenario these days.

这个问题很老了,但这些天我陷入了这种情况。

I tried every suggestion I read to solve the problem related to the npm installation process (npm cache clear and verify, uninstall and reinstall the package, uninstall and install everything and so on...) that looks like the "locked-in" syndrome. Nothing was successful in my case.

我尝试了我读到的每一个建议来解决与 npm 安装过程相关的问题(npm 缓存清除和验证、卸载和重新安装包、卸载和安装所有内容等等......),看起来像“锁定”综合症. 在我的案例中没有任何成功。

Once I found that my network was fully up and running without any firewall, proxy and/or strange routing rules I started installing packages with (example for the cli) npm install -g @angular/cli --verboseand I discovered that all the connections to the URL registry.npmjs.orgwere done in https. This was the problem in my case.

一旦我发现我的网络在没有任何防火墙、代理和/或奇怪的路由规则的情况下完全启动并运行,我开始安装包(例如 cli)npm install -g @angular/cli --verbose,我发现到 URL 的所有连接registry.npmjs.org都是在 https 中完成的。这就是我的问题。

For an unknown reason npm fails in a not very clear condition during the connection with the remote server, without any network error or warning. Simply it takes an huge amount of time to retrieve the data. Permissions? SSL certificates or some specific checking on it? Some strange route on the net?

由于未知原因,在与远程服务器连接期间,npm 在不太清楚的情况下失败,没有任何网络错误或警告。简单地说,检索数据需要大量时间。权限?SSL证书或对其进行一些特定检查?网上的一些奇怪的路线?

At the moment are just a speculations. I left the computer running all night and the packages were installed correctly but this is crazy. Isn't it?

目前只是一种猜测。我让计算机整夜运行,并且软件包安装正确,但这太疯狂了。不是吗?

After switching the connections to http with the command npm config set registry http://registry.npmjs.org/ --globaleverything has worked fine in a reasonable time for the installation packages process.

使用命令将连接切换到 http 后,npm config set registry http://registry.npmjs.org/ --global安装包过程在合理的时间内一切正常。

Probably there is something more that I'm missing but in my case the plain http has resolved the problem.

可能还有更多我遗漏的东西,但在我的情况下,普通的 http 已经解决了这个问题。

Ubuntu 18.04.1 LTS / node v8.12.0 / npm 6.4.1 / nvm 0.33.11

Ubuntu 18.04.1 LTS / node v8.12.0 / npm 6.4.1 / nvm 0.33.11

回答by Sami HK

This is how I resolved this after spending half an hour:

这就是我花了半小时后解决这个问题的方法:

  1. npm config set registry http://registry.npmjs.org/ --global
  2. npm cache clear --force
  3. setting package-lock.json to {}only
  4. npm install --verbose
  1. npm config set registry http://registry.npmjs.org/ --global
  2. npm cache clear --force
  3. 将 package-lock.json 设置为{}only
  4. npm install --verbose

node: v12.14.1 npm: v6.13.4

节点:v12.14.1 npm:v6.13.4

This issue occure when I tried running ng updateon angular 6 app to update it to angular 9.

当我尝试ng update在 angular 6 应用程序上运行以将其更新为 angular 9时出现此问题。

回答by RoshanADK

Adding to @CptUnlucky's answer.

添加到@CptUnlucky 的答案。

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

This forces the http fetch. If this alone doesn't work, throttle the number of simultaneous connections that can be established. Default Max connections is 50.

这会强制 http 获取。如果仅此一项不起作用,请限制可以建立的同时连接的数量。默认最大连接数为 50。

npm set maxsockets 3

That worked for me.

那对我有用。

回答by Tejaswi Vadakapur

You can try by setting the configuration to:

您可以尝试将配置设置为:

 npm config set registry

It works for me

这个对我有用

回答by Seth Holladay

I have experienced this and fixed it with rm -rf ~/.npmor npm cache clean.

我已经经历过这种情况并使用rm -rf ~/.npmor修复它npm cache clean

If that doesn't work, perhaps install with Homebrew instead of nvm, to eliminate some possibilities.

如果这不起作用,也许使用 Homebrew 而不是 nvm 安装,以消除一些可能性。

回答by Lekens

I solve this issue by opening the package-lock.jsonand reset all the json. Delete the current content and replace it with

我通过打开package-lock.json并重置所有 json 来解决这个问题。删除当前内容并替换为

{}

{}

then reinstall the package.

然后重新安装包。

回答by Qin Bo

  1. REASON: the reason for this is: the cli do not prompt: "Enter passphrase for /home/USERS/.ssh/id_rsa:" and I used to get the prompt correctly in npm@5, but update to npm@6, it occurs.
  2. SOLVE: # eval `ssh-agent` # ssh-add //automaticlly enter passphrase, without maunally operating.
  1. 原因:原因是:cli不提示:“为/home/USERS/.ssh/id_rsa输入密码:”我曾经在npm@5中正确获得提示,但更新到npm@6,它发生。
  2. SOLVE: # eval `ssh-agent` # ssh-add //自动输入密码,无需手动操作。

回答by SkorpEN

In my case removing packge connected to the one that loads forever solve issue

在我的情况下,删除连接到永远加载的包解决问题

    "swagger-core-api": "apigee-127/swagger-core-api" //removing this 

But the real reason of similar problems is project without full git data pushed to github(due to mess in .gitconfig). Then github clone copy files that not match one in repository (or Download ZIP).

但类似问题的真正原因是项目没有推送到 github 的完整 git 数据(由于 .gitconfig 中的混乱)。然后 github 克隆复制与存储库中不匹配的文件(或下载 ZIP)。

回答by Mark Hymanson

Probably not the best solution, but my workaround was to push up my active branches to origin, re-clone my repo into a different folder, then npm install in the new folder.

可能不是最好的解决方案,但我的解决方法是将我的活动分支推送到原点,将我的 repo 重新克隆到不同的文件夹中,然后在新文件夹中安装 npm。