npm ERR! network getaddrinfo ENOTFOUND

2019-01-11 09:17发布

I am getting npm ERR! network getaddrinfo ENOTFOUND error while trying to install any package using NPM. I know there are numerous threads on the same issue but I could not find any thread which can help me.

I have set the proxy & I think its something to do with proxy not being set correctly\not using the correct url.

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

Is there any way to check the URL I am using while setting proxy is correct? Are there any steps I need to take in order rectify this issue?

enter image description here

标签: node.js npm
11条回答
乱世女痞
2楼-- · 2019-01-11 09:43

I got the exact same error and this is what i did.

npm config get proxy

and it returned "null"

Opened "C:\Users\Myname.npmrc" in a notepad and made some changes. This is how my .npmrc file looks now

http-proxy=http://proxyhost/:proxyport
strict-ssl=false
registry=http://registry.npmjs.org/
查看更多
ら.Afraid
3楼-- · 2019-01-11 09:47

I had incorrectly typed in the address as

http://addressOfProxy.8080

instead of

http://addressOfProxy:8080  

(Notice the colon before the port number 8080.)

查看更多
我欲成王,谁敢阻挡
4楼-- · 2019-01-11 09:48

for some reason my error kept pointing to the "proxy" property in the config file. Which was misleading. During my troubleshooting I was trying different values for the proxy and https-proxy properties, but would only get the error stating to make sure the proxy config was set properly, and pointing to an older value.

Using, NPM CONFIG LS -L command lists all the properties and values in the config file. I was then able to see the value in question was matching the https-proxy, therefore using the https-proxy. So I changed the proxy (my company uses different ones) and then it worked. figured I would add this, as with these subtle confusing errors, every perspective on it helps.

查看更多
虎瘦雄心在
5楼-- · 2019-01-11 09:49

I was setting proxy as

npm config set http_proxy=http://domain:8080

instead of using the correct way

npm config set proxy http://domain:8080
查看更多
够拽才男人
6楼-- · 2019-01-11 09:52

does your proxy require you to authenticate? because if it does, you might want you configure your proxy like this.

placeholder names. username is a placeholder for your actual username. password is a placeholder for your actual password. proxy.company.com is a placeholder for your actualy proxy *port" is your actualy port the proxy goes through. its usualy 8080

npm config set proxy "http://username:password@proxy.company.com:port"
npm config set https-proxy "http://username:password@proxy.company.com:port"
查看更多
ら.Afraid
7楼-- · 2019-01-11 09:52
登录 后发表回答