无法更改npm代理设置

时间:2019-06-28 11:24:42

标签: npm

我正在尝试使用以下命令从npm安装ExpressJs:

npm i express

但是我遇到了以下错误:

npm ERR! Linux 4.15.0-50-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "i" "express"
npm ERR! node v8.10.0
npm ERR! npm  v3.5.2
npm ERR! code ECONNRESET

npm ERR! network tunneling socket could not be established, cause=connect ETIMEDOUT 10.7.0.1:8080
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! Please include the following file with any support request:
npm ERR!     /home/akhil/npm-debug.log

我怀疑这是代理错误。我以前使用的是代理服务器(错误10.7.0.1:8080中提到),但是现在我不希望使用代理服务器,并试图删除它,因为我已经尝试了以下命令:

npm config rm proxy
npm config rm https-proxy

我也尝试将-g添加到上述命令中 我也用过

set HTTP_PROXY=null
set HTTPS_PROXY=null

使用命令时

npm config ls -l

它显示代理和https-proxy都等于null。但是看来代理在查看错误时实际上并没有改变。

对于如何处理此错误的任何帮助,我们将不胜感激。

1 个答案:

答案 0 :(得分:1)

首先,将代理设置为假

npm config set proxy false

然后清理缓存

npm cache clean

如果这对您没有帮助,并且您正在使用代理,请尝试以下操作:

npm config set proxy http://proxyhost:proxyport
npm config set https-proxy http://proxyhost:proxyport