node.js npm 不工作 - “读取 ECONNRESET”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18419144/
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 not working - "read ECONNRESET"
提问by Omar
I'm having a problem with npm, I cant install anything. Here is the error messages:
我的 npm 有问题,我无法安装任何东西。以下是错误消息:
C:\Windows\system32>npm install -g yo
npm http GET https://registry.npmjs.org/yo
npm http GET https://registry.npmjs.org/yo
npm http GET https://registry.npmjs.org/yo
npm ERR! network read ECONNRESET
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 settin
gs.
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 Windows_NT 6.2.9200
npm ERR! command "C:\Program Files\nodejs\\node.exe" "C:\Program Files\nod
ejs\node_modules\npm\bin\npm-cli.js" "install" "-g" "yo"
npm ERR! cwd C:\Windows\system32
npm ERR! node -v v0.10.17
npm ERR! npm -v 1.3.8
npm ERR! syscall read
npm ERR! code ECONNRESET
npm ERR! errno ECONNRESET
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! C:\Windows\system32\npm-debug.log
npm ERR! not ok code 0
Any idea why is this? Here are my network settings and it seems I dont have any proxy configured. I also disabled all the firewalls.
知道这是为什么吗?这是我的网络设置,似乎我没有配置任何代理。我还禁用了所有防火墙。


回答by mithunsatheesh
use
用
npm config set registry http://registry.npmjs.org/
so that npm requests for httpurl instead of https.
以便 npm 请求httpurl 而不是https.
and then try the same npm installcommand
然后尝试相同的npm install命令
回答by jediz
You may want to check your NPM proxy settings and perhaps remove it.
您可能需要检查您的 NPM 代理设置并可能将其删除。
npm config get proxy
npm config rm proxy
npm config rm https-proxy
One might expect a fresh install of NodeJS+NPM would not have a proxy configured. Strangely enough, mine did come with a proxy defined, pointing to an IP and port 3128. Removing the proxy did the trick.
人们可能会期望全新安装的 NodeJS+NPM 不会配置代理。奇怪的是,我的确实定义了一个代理,指向一个 IP 和端口 3128。删除代理就成功了。
回答by Dmitri Mogilevski
You may also need to specify the proxy server/port, in some environments the system settings for proxy are not enough for npm to work.
您可能还需要指定代理服务器/端口,在某些环境中,代理的系统设置不足以让 npm 工作。
npm config set proxy "http://your-proxy.com:80"
回答by Ignatius Andrew
Remove your proxy settings at home and switch on at Office networks, This may be irritating, But It worked for me:
在家里删除您的代理设置并在 Office 网络上打开,这可能很烦人,但它对我有用:
npm config set proxy http://xxx.xxx.xxx.4:8080
npm config set https-proxy http://xxx.xxx.xxx.4:8080
and
和
npm config rm proxy
npm config rm https-proxy
回答by Kevin Cooper
This can be caused by installing anything with npm using sudo-- this causes the files in the cache to be owned by root, resulting in this problem. You can fix it by running:
这可能是通过使用 npm 安装任何东西引起的sudo——这会导致缓存中的文件归 root 所有,从而导致此问题。您可以通过运行来修复它:
sudo rm -rf ~/.npm
sudo rm -rf ~/.npm
to remove the cache. Then try whatever you were doing again, making sure you never use sudoalong with npm(or the problem may come back).
删除缓存。然后再试一次你正在做的事情,确保你永远不会sudo一起使用npm(否则问题可能会再次出现)。
Lots more information: npm throws error without sudo
回答by Himanshu sharma
The three thing to make npm working well inside the proxy network .
使 npm 在代理网络中运行良好的三件事。
This set npm registry , By default it may take https.
这个设置 npm registry ,默认情况下它可能需要 https。
npm config set registry "http://registry.npmjs.org/"
npm 配置设置注册表“ http://registry.npmjs.org/”
Second is two set proxy in your system . If your organization use proxy or you.
其次是您系统中的两套代理。如果您的组织使用代理或您。
npm config set proxy "http://username:password@proxy-url:proxy-port"
npm config set https-proxy "http://username:password@proxy-url:proxy-port"
npm 配置设置代理“ http://username:password@proxy-url:proxy-port”
npm 配置设置 https-proxy " http://username:password@proxy-url:proxy-port"
You can also check if they are set or not , by
您还可以检查它们是否已设置,通过
npm config get https-proxy
npm 配置获取 https 代理
for all values.
对于所有值。
回答by Nuhman
I've tried almost all methods posted here and in other pages but didn't work. Here are the commands I've executed in order, which I encourage you to try because it worked for many people (but not me):
我已经尝试了这里和其他页面中发布的几乎所有方法,但没有奏效。以下是我按顺序执行的命令,我鼓励您尝试这些命令,因为它对许多人(但不是我)有效:
npm config rm proxynpm config rm https-proxynpm config set https-proxy https://username:[email protected]:6050npm config set proxy http://username:[email protected]:6050npm config set registry http://registry.npmjs.org/
npm config rm proxynpm config rm https-proxynpm config set https-proxy https://username:[email protected]:6050npm config set proxy http://username:[email protected]:6050npm config set registry http://registry.npmjs.org/
And then trying to install the package npm install -g express, but it failed.
然后尝试安装该软件包npm install -g express,但失败了。
However, when I tried to run npm install npm@latest -git miraculouslyexecuted and installed fine!
Then running npm install -g expressagain worked perfectly fine too.
但是,当我尝试运行npm install npm@latest -g它时,它奇迹般地执行并安装得很好!
然后npm install -g express再次运行也完全正常。
TL;DR: updating npm to the latest version solved the issue (currently 6.0.1)
TL;DR:将 npm 更新到最新版本解决了这个问题(目前是 6.0.1)
回答by Gowtham
Restarting my PC made it worked.
重新启动我的电脑使它工作。
回答by sahi
Our company firewall will stop installing node hence connect to the personal network and install, it worked for me.
我们公司的防火墙将停止安装节点,因此连接到个人网络并安装,它对我有用。
回答by s_bighead
If you're using Windows you should follow up on Advanced System Settings to check the env vars declared over there, you should notice that the proxy configuration may lie within environment variables, like in the picture below:
如果您使用的是 Windows,您应该跟进高级系统设置以检查那里声明的环境变量,您应该注意到代理配置可能位于环境变量中,如下图所示:
So if your proxy server is not available or is blocking traffic from npm you might notice the aforementioned error in this topic. Maybe you don't need any proxy at all, in this case, just remove this HTTP_PROXY env variables.
因此,如果您的代理服务器不可用或阻止来自 npm 的流量,您可能会注意到本主题中的上述错误。也许您根本不需要任何代理,在这种情况下,只需删除此 HTTP_PROXY 环境变量即可。
I had turned all proxy configurations off in my Windows and npm settings, however, npm was still getting timeout and connection errors while downloading resources, then I figured out there was still a proxy configuration left on env variables, which was causing all the trouble.
我已经在 Windows 和 npm 设置中关闭了所有代理配置,但是,npm 在下载资源时仍然出现超时和连接错误,然后我发现 env 变量上仍然存在代理配置,这导致了所有问题。

