node.js ETIMEDOUT 在 Windows 上安装 Node 包时出错

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

ETIMEDOUT Error while installing Node packages on Windows

windowsnode.jsnpm

提问by EagleEye

I am trying to install node packages on my windows machine using npm from a fresh install of node.

我正在尝试使用来自全新安装的节点的 npm 在我的 Windows 机器上安装节点包。

however, I am getting ETIMEDOUT errors. I checked few other stackoverflow questions with similar problem and almost all of them are related to problems when behind a proxy. Same is not the case with me. My system is not behind any proxy server. Can someone help me with resolving it.

但是,我收到 ETIMEDOUT 错误。我检查了一些其他具有类似问题的 stackoverflow 问题,几乎所有问题都与代理背后的问题有关。我的情况也不是这样。我的系统不在任何代理服务器后面。有人可以帮我解决它。

PS C:\windows\system32> npm -v
2.5.1
PS C:\windows\system32> npm install bower -g
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\Program Files\nodejs\\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "i
nstall" "bower" "-g"
npm ERR! node v0.12.0
npm ERR! npm  v2.5.1
npm ERR! code ETIMEDOUT
npm ERR! errno ETIMEDOUT
npm ERR! syscall connect

npm ERR! network connect ETIMEDOUT
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:\windows\system32\npm-debug.log

回答by EagleEye

I am posting this answer in case some one faces the same issue.

如果有人面临同样的问题,我将发布此答案。

I was able to solve this by running following command:

我能够通过运行以下命令来解决这个问题:

npm config delete proxy

回答by Nadun Kulatunge

First, run npm config listand check whether you are behind a proxy. If so, try running

首先,运行 npm config list并检查您是否在代理后面。如果是这样,请尝试运行

npm config delete proxy
npm config delete http-proxy
npm config delete https-proxy

as required

按要求

**If this method did not work, reinstall nodejs.

**如果此方法无效,请重新安装nodejs。

回答by Gábor Nagy

I tried all the suggested solutions I could find on GitHub forums and StackOverflow topics. Finally disabling my router's firewallsolved the issue immediately.

我尝试了所有可以在 GitHub 论坛和 StackOverflow 主题上找到的建议解决方案。最后禁用我的路由器的防火墙立即解决了这个问题。

I am using Windows 10, node 4.0.0 and npm 2.13.4.

我使用的是 Windows 10、节点 4.0.0 和 npm 2.13.4。

回答by Diego Figueroa

First see the npm config list:

首先查看 npm 配置列表:

npm config list

If you don't find http-proxy, https-proxyand proxy correctlyset, then You need to configure npm to work with your web proxy. For example:

如果你没有找到http-proxyhttps-proxyproxy correctly集,则需要配置NPM工作与你的Web代理。例如:

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

回答by Erwin Mayer

You can try to throttle the number of simultaneous connections with the following command (for example 3 maximum simultaneous connections):

您可以尝试使用以下命令限制同时连接的数量(例如 3 个最大同时连接):

npm set maxsockets 3

The CLI has been allowing this option since [email protected]. The default is 50 simultaneous connections max. See this linkfor further reference.

[email protected] 以来,CLI 一直允许此选项。默认值是最多 50 个同时连接。请参阅此链接以获取进一步参考。

回答by Danilo Gutiérrez

I solved with:

我解决了:

npm config set proxy null

回答by guntarion

I solved it with the following:

我用以下方法解决了它:

npm config rm proxy
npm config rm https-proxy

npm config delete http-proxy
npm config delete https-proxy

set HTTP_PROXY=null
set HTTPS_PROXY=null

回答by M M

For people working in corporates (where you cannot delete or edit the proxy configuration of the organization):

对于在公司工作的人(您无法删除或编辑组织的代理配置):

There must be an .npmrcfile in your users folder. If not, you can create one. This file can be edited to register the proxy settings of your organization. Contact your organization's IT team to get the relevant proxy details.

.npmrc您的用户文件夹中必须有一个文件。如果没有,您可以创建一个。可以编辑此文件以注册您组织的代理设置。联系您组织的 IT 团队以获取相关代理详细信息。

Example of the .npmrcfile contents for my organization:

.npmrc我的组织的文件内容示例:

strict-ssl=false
registry=https://nexus.com/nexus/content/groups/npm-read/
proxy=http://primary-proxy.gslb.intranet.com:8080/
https-proxy=http://primary-proxy.gslb.intranet.com:8080

This file can be found in your users folder:

该文件可以在您的用户文件夹中找到:

enter image description here

在此处输入图片说明

回答by nishant kaushik

I was going through the same error. the root cause was the proxy settings : there are several answers provided in here to reset the proxy but none of them worked for me. Below commands solved my problem, give them a try.

我正在经历同样的错误。根本原因是代理设置:这里提供了几个重置代理的答案,但没有一个对我有用。下面的命令解决了我的问题,试试看。

npm config rm proxy 
npm config rm https-proxy