NPM模块安装错误
我得到错误:隧道套接字无法build立,导致= getaddrinfo ENOTFOUND而试图在node.js中安装模块。 这似乎有一些代理错误。我检查了浏览器设置,代理被禁用。 但是,当我在命令提示符检查npmconfiguration获取代理,得到192.168.98.5:8080。 如何禁用这个?
首先,尝试执行npm config delete proxy
。 如果你得到Error: ENOENT, unlink '/Users/drlazor/.npmrc'
是好的; 这意味着你没有npmconfiguration文件,因此没有代理设置。
其次,validation你没有使用npm config get proxy
代理设置。 你应该得到一个null
或上面的错误。 如果你继续得到一个不同于null
的结果,你还应该确保你没有设置环境variablesHTTP_PROXY
。
第三和最后,如果没有这些工作,尝试从您的浏览器访问URL; 毕竟这可能是一个networking问题。
您应该检查npmconfiguration页面如何设置和修改configuration值。 代理密钥存储用于连接到npm存储库的代理服务器。 尝试这个 :
npm config delete proxy
注意:如果你不在代理之后,这是有效的(从个人计算机)
首先执行这个命令
npm config edit
npmconfiguration文件在打开的文件的两行之后打开注释,在行的开头加上“;”(分号) 。
npm config set proxy http://proxy.company.com:8080
npm config set https-proxy http://proxy.company.com:8080
你完成了。 现在安装你想要的任何包。
npm install -g cordova npm install -g npm
或者其他你需要安装的东西
我处于相同的状态,并得到了这个错误,因为代理值的格式错误(我只是想念“http://”在代理值的开始)。
如果应该设置一个代理,这里是格式(值取决于你的networking):
npm config set proxy http://proxy.mydomain:3128
npm config set https-proxy http://proxy.mydomain:3128
如果您的NPMconfiguration为使用不同的NPM注册服务器(可能位于工作机器上,未连接到networking/ VPN),也会发生这种情况。 要看是否是这样的情况:
npm config edit
并寻找:
registry=http://alternateurl
默认是:
https://registry.npmjs.org/
您可以连接到您的VPN /networking或更改该configuration更正。
你需要设置全部3个代理
npm config set proxy http://proxy.name.xx:port npm config set http-proxy http://proxy.name.xx:port npm config set https-proxy http://proxy.name.xx:port
如果您没有代理使用以下命令:
npm config delete https-proxy npm config delete proxy
如果您使用代理使用:
npm config set proxy $PROXY npm config set http-proxy $PROXY
两者都倾向于工作
如果通过terminal设置代理或创build.npmrc没有帮助,请尝试将.typingsrc文件放在c:\ Users \'username'中,并带有以下内容
{ "proxy": "http://proxy.name.xx:port", "https-proxy": "http://proxy.name.xx:port", "strict-ssl": false }