npm ERR! Error: connect ECONNREFUSED

2019-01-07 23:52发布

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:

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

4条回答
走好不送
2楼-- · 2019-01-08 00:27

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 me is adding additional fields to host file (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 issue on npm repository where this solution is approved by npm contributors.

查看更多
相关推荐>>
3楼-- · 2019-01-08 00:40

If you are behind a proxy, please make sure that the npm ERR! 'proxy' config is set properly. See: 'npm help config'

See:

More info:

查看更多
smile是对你的礼貌
4楼-- · 2019-01-08 00:52

Try:

npm config set proxy null
npm config set https-proxy null
npm config set registry http://registry.npmjs.org/
查看更多
爷、活的狠高调
5楼-- · 2019-01-08 00:52

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:

npm config set proxy http://jdoe:password123@proxy.company.com:8080 npm config set https-proxy http://jdoe:password123@proxy.company.com: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).

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.

查看更多
登录 后发表回答