node.js NPM doesn't install any modules: network socket hangs up
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20397883/
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 doesn't install any modules: network socket hangs up
提问by Nasser Torabzade
Salam (means Hello) :)
Salam (means Hello) :)
I have the latest version of node.js installed on ubuntu 12.04, I'm not behind any proxies, and my network settings are correctly configured, and were intact since last time when NPM worked fine. But now NPM hangs up installation of any modules with following error:
I have the latest version of node.js installed on ubuntu 12.04, I'm not behind any proxies, and my network settings are correctly configured, and were intact since last time when NPM worked fine. But now NPM hangs up installation of any modules with following error:
nasser@nasser-desktop:~/projects/server v3$ npm install simple-proxy
npm WARN package.json [email protected] No repository field.
npm http GET https://registry.npmjs.org/simple-proxy
npm http GET https://registry.npmjs.org/simple-proxy
npm http GET https://registry.npmjs.org/simple-proxy
npm ERR! network socket hang up
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! System Linux 3.5.0-17-generic
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install" "simple-proxy"
npm ERR! cwd /home/nasser/projects/serverV3
npm ERR! node -v v0.10.18
npm ERR! npm -v 1.3.8
npm ERR! code ECONNRESET
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/nasser/projects/serverV3/npm-debug.log
npm ERR! not ok code 0
回答by pajooh
i had same problem. it seems that there is some problem with ISP's https handling. doing:
i had same problem. it seems that there is some problem with ISP's https handling. doing:
npm config set registry http://registry.npmjs.org/
worked for me
worked for me
回答by Marina
I was having the same problem. Found a solution in this thread.
You can see the effective proxy that npmis using by doing:
I was having the same problem. Found a solution in this thread.
You can see the effective proxy that npmis using by doing:
npm config get proxy
npm config get https-proxy
If you're behinid a proxy, try this:
If you're behinid a proxy, try this:
mv ~/.npmrc ~/.npmrc.bak
回答by Fahid Mohammad
I was having a similar issue with my windows machine and i fixed it by first checking whether my proxy got some value by executing the below command.
I was having a similar issue with my windows machine and i fixed it by first checking whether my proxy got some value by executing the below command.
npm config get proxy
in return i got the below:
in return i got the below:
http://usr:pwd@host/:port
So if anyone who is not under a proxy layer first set the proxy as null by executing the below command.
So if anyone who is not under a proxy layer first set the proxy as null by executing the below command.
npm config set proxy null
now if you excecute your npm i it should not throw any network error.
now if you excecute your npm i it should not throw any network error.
回答by Santosh Sindham
If you are behind a proxy that has username and password authentication, try setting the proxy as
If you are behind a proxy that has username and password authentication, try setting the proxy as
npm config set proxy http://username:encodedpassword@proxyaddress:port
npm config set proxy http://username:encodedpassword@proxyaddress:port
npm config set https-proxy http://username:encodedpassword@proxyaddress:port
npm config set https-proxy http://username:encodedpassword@proxyaddress:port
回答by Kabiraj Kharel
Just follow these steps before you run: npm install -g @angular/cli
Just follow these steps before you run: npm install -g @angular/cli
npm cache clean(You can even ignore if it throws an error)npm config set strict-ssl falsenpm config set proxy http://myusername:mypassword@proxyaddress:portnpm config set https-proxy http://myusername:mypassword@proxyaddress:port
npm cache clean(You can even ignore if it throws an error)npm config set strict-ssl falsenpm config set proxy http://myusername:mypassword@proxyaddress:portnpm config set https-proxy http://myusername:mypassword@proxyaddress:port
回答by Maha
Add the proxy and http_proxy field with your credentials (encoded if it contains any special characters) to your .npmrc file and run npm install again. It should work.
Add the proxy and http_proxy field with your credentials (encoded if it contains any special characters) to your .npmrc file and run npm install again. It should work.
for example:
for example:
proxy=http://username:passcode@proxyURL:80/https_proxy=http://username:passcode@proxyURL:80
proxy=http://username:passcode@proxyURL:80/https_proxy=http://username:passcode@proxyURL:80
回答by Vrushal Raut
I tried multiple solution but most of cases happened with me is network/ssl and proxy issue.Network/ssl cases are very common and their are bunch of solution but with proxy thing I shared my fixes with you.
I tried multiple solution but most of cases happened with me is network/ssl and proxy issue.Network/ssl cases are very common and their are bunch of solution but with proxy thing I shared my fixes with you.
Bash Commands:
Bash Commands:
npm config set proxy null
npm config set https-proxy null
npm config set http-proxy null
in my case I'm using https://registry.npmjs.org/url. After NULL proxy its start working. npm set default proxy as http://my-proxy.com:1080/so either we have to change proxy url or null it. To get your default proxy hit below command in your bash.
in my case I'm using https://registry.npmjs.org/url. After NULL proxy its start working. npm set default proxy as http://my-proxy.com:1080/so either we have to change proxy url or null it. To get your default proxy hit below command in your bash.
npm config get proxy
回答by Haruna Akhmad
Find .npmrc file, open with note pad. then delete the proxy setting there
Find .npmrc file, open with note pad. then delete the proxy setting there

