我有一个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

知道为什么吗?这是我的网络设置,似乎我没有配置任何代理。我还关闭了所有的防火墙。


当前回答

我最近安装了Fiddler,它(我不知道)通过127.0.0.1:8866添加了一个网络代理。我进入我的Ubuntu网络设置,点击进入“网络代理”设置,并禁用它,然后一切恢复正常。

所以一般来说,检查确保你没有因为你正在做的其他事情的副作用而设置网络代理。

其他回答

当我试图在Oracle VirtualBox中模拟的系统上运行npm时,我也遇到了同样的问题。我通过在网络适配器属性中添加谷歌DNS地址来解决它。

网卡属性> IPv4属性>首选DNS地址:8.8.8.8。

use

npm config set registry http://registry.npmjs.org/

所以NPM请求HTTP url而不是https。

然后试试同样的NPM安装命令

这对我来说很管用:

proxy = http://1.1.1.1:3128/
https_proxy = http://1.1.1.1:3128/
strict-ssl = false
ca = null
registry = http://registry.npmjs.org/

答案在这里:https://fak3r.com/2015/07/31/howto-use-npm-behind-a-corporate-proxy/

让npm在代理网络中正常工作的三件事。

这个设置npm注册表,默认可能采用https。

NPM配置注册表http://registry.npmjs.org/

其次是在您的系统中设置两个代理。如果您的组织使用代理或您。

NPM配置代理“http://username:password@proxy-url:proxy-port” NPM设置http -proxy “http://username: password@proxy-url:代理端口”

您还可以检查它们是否已设置,通过

NPM配置http -proxy

对于所有的值。

就我而言,换wifi对我来说很有用。我通常在客厅里工作。但是我几天前刚换了房间。wifi没有到达二楼,所以我们使用了wifi Extender。

然后我遇到了这个问题。我试着切换回客厅的wifi,执行同样的命令也没有问题。