node.js 错误:getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443

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

Error : getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443

angularjsnode.jswindowsnpmnpm-install

提问by Bhuvana K

I am working on a corporate network.

我在公司网络上工作。

Trying to install npm.But I'm getting this error again and again.

正在尝试安装npm.但我一次又一次地收到此错误。

$ npm install
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Program     Files\nodejs\node_modules\npm\bin\npm-cli.js" "install"
npm ERR! node v6.1.0
npm ERR! npm  v3.8.6
npm ERR! code ENOTFOUND
npm ERR! errno ENOTFOUND
npm ERR! syscall getaddrinfo

npm ERR! network getaddrinfo ENOTFOUND registry.npmjs.org    registry.npmjs.org:443
npm ERR! network This is most likely not a problem with npm itself
npm ERR! network and is related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly.  See: 'npm help config'

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Angular-test\angular-phonecat\npm-debug.log

Tried this also: npm config set registry https://registry.npmjs.org/

也试过这个: npm config set registry https://registry.npmjs.org/

Still getting the same error.

仍然得到同样的错误。

回答by rsp

Things to try:

尝试的事情:

  1. make sure you have internet connection: ping 8.8.8.8
  2. make sure you have DNS resolver working: ping www.google.com
  3. make sure you can access registry.npmjs.org: ping registry.npmjs.org
  4. make sure you can connect via https.
  1. 确保您有互联网连接: ping 8.8.8.8
  2. 确保您的 DNS 解析器正常工作: ping www.google.com
  3. 确保您可以访问 registry.npmjs.org: ping registry.npmjs.org
  4. 确保您可以通过 https 连接。

Try in your browser: https://registry.npmjs.org/

在浏览器中尝试:https: //registry.npmjs.org/

Make sure you are trying to connect to:

确保您尝试连接到:

  • registry.npmjs.org
  • registry.npmjs.org

and not to:

而不是:

  • "registry.npmjs.org registry.npmjs.org:443"
  • "registry.npmjs.org registry.npmjs.org:443"

or some other weird string composed of few hostnames, because it's weird that the resolver complains about a hostnames that includes a port number, which it shouldn't care about. Ok, I tested and it should look like this for hosts that are not found.

或其他一些由少数主机名组成的奇怪字符串,因为解析器抱怨包含端口号的主机名很奇怪,它不应该关心。好的,我进行了测试,对于找不到的主机,它应该看起来像这样。

Update

更新

From your comment to this answer it seems that you are notdirectly connected to the internet if you can't even ping 8.8.8.8.

从您对此答案的评论来看,如果您甚至无法 ping 8.8.8.8 ,您似乎并没有直接连接到互联网。

If you are using a proxy to access the Web, then you also have to configure npmto use it. Use:

如果您使用代理访问 Web,则还必须进行配置npm才能使用它。用:

npm config set proxy http://example.com:8080
npm config set https-proxy http://example.com:8080

but instead of http://example.com:8080use what you actually need in your company - ask someone or see how your browser is configured.

但不要http://example.com:8080使用您公司实际需要的东西 - 询问某人或查看您的浏览器是如何配置的。

To see your proxy configuration in Chrome, see this.

要在 Chrome 中查看您的代理配置,请参阅

Update 2

更新 2

If you canaccess https://registry.npmjs.org/in your browser but you cannotrun ping registry.npmjs.orgthen it means that your browser must be configured to use a proxy, or other programs than your browser must be restricted from using the internet.

如果您可以在浏览器中访问https://registry.npmjs.org/无法运行,ping registry.npmjs.org则意味着您的浏览器必须配置为使用代理,或者必须限制浏览器以外的其他程序使用互联网。

In any case, you should ask someone in your company about it because most likely you either need to use a specific proxy or someone needs to lift the restriction from your npmand allow it to access the network.

在任何情况下,您都应该询问公司中的某个人,因为很可能您要么需要使用特定代理,要么需要有人解除您的限制npm并允许其访问网络。

The network access can be blocked by a firewall installed on your computer or a router in your network. It's hard to say without knowing the specific configuration in your company.

计算机上安装的防火墙或网络中的路由器可能会阻止网络访问。不知道贵公司的具体配置就很难说。

Update 3

更新 3

Remove the environment variable "https_proxy" if any or use correct value for "https_proxy"

删除环境变量“https_proxy”(如果有)或为“https_proxy”使用正确的值

回答by jansanchez

First, edit NetworkManager.conf file:

首先,编辑 NetworkManager.conf 文件:

vim /etc/NetworkManager/NetworkManager.conf

Comment this line:

评论这一行:

#dns=dnsmasq

Finally

最后

sudo service network-manager restart
sudo service docker restart

回答by malith vitha

use: https://registry.npmjs.org/Make sure you are trying to connect to:

使用:https: //registry.npmjs.org/确保您尝试连接到:

registry.npmjs.org

registry.npmjs.org

if there is no error,try to clear cache

如果没有错误,请尝试清除缓存

npm cache clean --force then try npm install

npm cache clean --force 然后尝试 npm install

even you have any error

即使你有任何错误

npm config set registry https://registry.npmjs.org/then try npm install -g @angular/cli

npm config set registry https://registry.npmjs.org/然后尝试 npm install -g @angular/cli

回答by Nagendra Reddy

I tried many but this worked fine for me.

我尝试了很多,但这对我来说很好。

npm config rm proxy
npm config rm https-proxy

above 2 commands is enough if it doesn't work try this as well.

如果它不起作用,以上 2 个命令就足够了,也试试这个。

npm config --global rm proxy
npm config --global rm https-proxy

回答by abdulbarik

As I think if system is connected to the internet then it's may be an issue of proxy

我认为如果系统连接到互联网,那么它可能是一个问题 proxy

Do this to delete proxy

这样做删除 proxy

npm config delete proxy

npm config 删除代理

回答by Nagnath Bhat

You can use this command

你可以使用这个命令

npm config delete proxy

It happens because formidableis prone to severity vulnerability. So, you need to override that by running the above command.

发生这种情况是因为formidable容易出现严重漏洞。因此,您需要通过运行上述命令来覆盖它。

回答by Kai Abat

I have a fresh Windows 10 installed on my PC and tried this on the command line and it works like a charm:

我在我的 PC 上安装了一个全新的 Windows 10,并在命令行上尝试了这个,它就像一个魅力:

npm config rm https-proxy

npm config rm https-proxy

回答by Jomy John

I had the same issue. The reason was the corporate proxy issue. Solution was to set the proxy setting as @rsp says.

我遇到过同样的问题。原因是公司代理问题。解决方案是像@rsp 所说的那样设置代理设置。

npm config set proxy http://example.com:8080
npm config set https-proxy http://example.com:8080

But later I face the same issue. This time reason was my password contains a special character.

但后来我面临同样的问题。这次的原因是我的密码包含一个特殊字符。

In this command you can't provide a password with special character

在此命令中,您不能提供带有特殊字符的密码

. So solution is to provide percentage encoded special character in the password.

. 所以解决方案是在密码中提供百分比编码的特殊字符。

For example # has to provide as %23

例如 # 必须提供为 %23

https://www.w3schools.com/tags/ref_urlencode.asp

https://www.w3schools.com/tags/ref_urlencode.asp

回答by Developer

I spent over 5 hours trying to get rid of this message under Windows 8.1. So I would like to share my case and save someones time. I was not behind the proxy... but setting proxy helped to resolve the problem. So I go deep and found that issue was caused by Comodo Firewall... which blocked cmd since I was installing packages too fast (turning off and even closing Firewall did not help, which caused me so long to find the issue... seems like there was some other process of Firewall running in background). You may have same issue with any other firewall/antivirus installed so make sure that cmd is not blocked by them. Good luck!

我花了 5 多个小时试图在 Windows 8.1 下摆脱此消息。所以我想分享我的案例并节省别人的时间。我并不支持代理...但设置代理有助于解决问题。所以我深入研究发现问题是由 Comodo Firewall 引起的...它阻止了 cmd 因为我安装软件包太快(关闭甚至关闭防火墙都没有帮助,这让我很长时间才找到问题...似乎就像在后台运行其他一些防火墙进程一样)。您安装的任何其他防火墙/防病毒软件都可能遇到同样的问题,因此请确保 cmd 没有被它们阻止。祝你好运!

回答by Tiago Ferreira

If Ubuntu try opening All Settings > Network > Network proxy set the method to automatic and save.

如果 Ubuntu 尝试打开所有设置 > 网络 > 网络代理,将方法设置为自动并保存。