NPM module installation error

故事扮演 提交于 2019-11-30 15:09:55

问题


I am getting Error: tunneling socket could not be established, cause=getaddrinfo ENOTFOUND while trying to install a module in node.js. It seems some proxy error.I checked in browser setting ,proxy is disabled. But when i am checking in command prompt npm config get proxy, getting 192.168.98.5:8080. How to disable this?


回答1:


First, try to execute npm config delete proxy. If you get something like Error: ENOENT, unlink '/Users/drlazor/.npmrc' is OK; that means you don't have a npm config file and, therefore, no proxy settings.

Second, verify you have no proxy settings with npm config get proxy. You should get a nullor the above error. If you keep on getting a result different from null, you should also ensure you haven't set the environment variable HTTP_PROXY.

Third and last, if none of those worked, try accessing the URL from your browser; it could be a network issue after all.




回答2:


You should check the npm config page on how to set and modify config values. proxy key stores proxy server to use to connect to npm repositories. Try this :

npm config delete proxy



回答3:


Note: This Works if you are not behind a Proxy i.e (From a Personal Computer)

First execute this command

npm config edit

npm the configuration file opens comment following two lines in the opened file by putting ";"(semi Colon) in start of the line.

npm config set proxy http://proxy.company.com:8080
npm config set https-proxy http://proxy.company.com:8080

You are done. Now install any package you want to.

npm install -g cordova
npm install -g npm

or anything else you need to install




回答4:


i was in the same state and got this error because of the wrong proxy value format (i just miss "http://" at the beginning of the proxies values).

If a proxy should be set, here is the format (values depend of your network) :

npm config set proxy http://proxy.mydomain:3128

npm config set https-proxy http://proxy.mydomain:3128




回答5:


This can also happen if your NPM is configured to use a different NPM registry server (possibly you are on a work machine and not connected to the network/VPN). To see if this is the case:

npm config edit

and look for:

registry=http://alternateurl

The default is:

https://registry.npmjs.org/

You can connect to your VPN/network or change that config to correct.




回答6:


You need to set all 3 proxy

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



回答7:


If you have no proxy use the following commands:

npm config delete https-proxy
npm config delete proxy

if you are using a proxy use:

npm config set proxy $PROXY
npm config set http-proxy $PROXY

Either of the two tend to work




回答8:


In case setting proxy via terminal or creating .npmrc does not help, try to put .typingsrc file in c:\Users\'username' with the following content

{
  "proxy": "http://proxy.name.xx:port",
  "https-proxy": "http://proxy.name.xx:port",
  "strict-ssl": false
}


来源:https://stackoverflow.com/questions/15569755/npm-module-installation-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!