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

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


当前回答

我找到了一个简单的解决办法。如果你使用的是Windows 10,那么进入网络设置并关闭自动代理检测。它解决了我的问题。过去两天我一直在找这个。

其他回答

如果保存的不记名令牌现在无效,也可能遇到此错误。我在使用私人回购时遇到过这种情况,其中帐户被擦除和重置,令牌无效。虽然你的回购可能不需要身份验证,如果你有一个令牌从以前的登录,它将被通过,如果它是无效的连接将被关闭。

您可以通过使用新的用户名和密码再次登录来解决这个问题,或者简单地通过npm注销。

我发现“npm config edit”对更新http -proxy, proxy, registry的条目更有用

我是这样做的

NPM配置列表 NPM配置编辑(在vi中打开) 编辑或设置http -proxy、代理、注册表的配置项 npm安装

去除纱线。锁,包锁。json, node_modules

然后

npm install -f 

为我工作

在家里删除你的代理设置,在办公室网络上打开,这可能会让人恼火,但对我来说很管用:

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

我不想切换到注册表的http,对我有用的是从最新的Node版本降级到LTS版本(目前是6.x)。