node.js 错误!错误:连接 ECONNREFUSED
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42371380/
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
npm ERR! Error: connect ECONNREFUSED
提问by NickJS
I'm trying to update the npm (node package manager) using the command: npm install npm@latest -g but I', getting the following error in the command prompt:
我正在尝试使用以下命令更新 npm(节点包管理器):npm install npm@latest -g 但是我在命令提示符中收到以下错误:
does someone know what this really means?
有人知道这到底是什么意思吗?
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@latest" "-g"
npm ERR! node v6.9.5
npm ERR! npm v3.10.10
npm ERR! code ECONNREFUSED
npm ERR! errno ECONNREFUSED
npm ERR! syscall connect
npm ERR! Error: connect ECONNREFUSED xxx.xxx.xx.xxx:xxx
npm ERR! at Object.exports._errnoException (util.js:1022:11)
npm ERR! If you are behind a proxy, please make sure that the
npm ERR! 'proxy' config is set properly. See: 'npm help config'
any help would be appreciated.
任何帮助,将不胜感激。
Thank you nickJS
谢谢你
采纳答案by rsp
If you are behind a proxy, please make sure that the npm ERR! 'proxy' config is set properly. See: 'npm help config'
如果您在代理后面,请确保 npm ERR!“代理”配置设置正确。请参阅:'npm 帮助配置'
See:
看:
More info:
更多信息:
回答by Ridd
Try:
尝试:
npm config set proxy null
npm config set https-proxy null
npm config set registry http://registry.npmjs.org/
The first two lines will remove proxy's if there any.
前两行将删除代理(如果有)。
Third line will make npmdownload from the official package registry.
第三行将从npm官方包注册表进行下载。
回答by arnold
I got a similar error when I was using Node JS behind a proxy server. Here's what I had to do to fix it:
当我在代理服务器后面使用 Node JS 时,我遇到了类似的错误。这是我必须做的来修复它:
npm config set proxy http://jdoe:[email protected]:8080
npm config set https-proxy http://jdoe:[email protected]:8080
Just replace "jdoe" and "password123" with your own credentials to access the proxy server. Everything after the @ is the server domain name, or you can enter the exact IP address too. In my case, both addresses were HTTP (not HTTPS).
只需用您自己的凭据替换“jdoe”和“password123”即可访问代理服务器。@ 之后的所有内容都是服务器域名,或者您也可以输入确切的 IP 地址。就我而言,两个地址都是 HTTP(不是 HTTPS)。
To confirm the changes, you can type:
要确认更改,您可以键入:
npm config list
and your settings should be listed.
并且应该列出您的设置。
You can get the proxy settings (address) from your browser too.
您也可以从浏览器获取代理设置(地址)。
回答by Arthur Vasilyev
I have been trying to fix this issue by
我一直在尝试解决这个问题
npm config set registry http://registry.npmjs.org/
npm config set proxy http://myproxyblabla:myport
npm config set https-proxy http://myproxyblabla:myport
But it didn't help. The only one solution which worked for meis adding additional fields to host file (C:\Windows\System32\drivers\etc\hosts)
但它没有帮助。唯一对我有用的解决方案是向主机文件添加其他字段(C:\Windows\System32\drivers\etc\hosts)
151.101.36.162 registry.npmjs.com
151.101.36.162 registry.npmjs.org
This allowes npm to resolve address to server from which it will download needed files. You can get familiar with closed issueon npm repository where this solution is approved by npm contributors.
这允许 npm 将地址解析到服务器,它将从中下载所需文件。您可以在 npm 存储库上熟悉已解决的问题,该解决方案由 npm 贡献者批准。
回答by mfaisalhyder
May be this will help someone in need. I turned to this solution after wasting good 2 hours as my corporate proxy server on work laptop was not getting resolved..!
也许这会帮助有需要的人。我在浪费了 2 个小时之后转向了这个解决方案,因为我的工作笔记本电脑上的公司代理服务器没有得到解决..!
I removed both proxyand https-proxyfrom .npmrcfile and set only
我从文件中删除了proxy和并且只设置了https-proxy.npmrc
npm config set registry http://registry.npmjs.org/
npm config set registry http://registry.npmjs.org/
Then, I am able to successfully run npm install -g create-react-app
然后,我能够成功运行 npm install -g create-react-app
.npmrcfile can be found here at C:\Users\<userName>\.npmrc
.npmrc文件可以在这里找到 C:\Users\<userName>\.npmrc
Cheers! Happy Quarantine Development:p
干杯! 快乐隔离发展:p

