'Error : getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443
I am working on a corporate network.
Trying to install npm. But I'm getting this error again and again.
$ npm install
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! node v6.1.0
npm ERR! npm v3.8.6
npm ERR! code ENOTFOUND
npm ERR! errno ENOTFOUND
npm ERR! syscall getaddrinfo
npm ERR! network getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443
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! C:\Angular-test\angular-phonecat\npm-debug.log
Tried this also: npm config set registry https://registry.npmjs.org/
Still getting the same error.
Solution 1:[1]
Things to try:
- make sure you have internet connection:
ping 8.8.8.8 - make sure you have DNS resolver working:
ping www.google.com - make sure you can access registry.npmjs.org:
ping registry.npmjs.org - make sure you can connect via https.
Try in your browser: https://registry.npmjs.org/
Make sure you are trying to connect to:
registry.npmjs.org
and not to:
"registry.npmjs.org registry.npmjs.org:443"
or some other weird string composed of few hostnames, because it's weird that the resolver complains about a hostnames that includes a port number, which it shouldn't care about. Ok, I tested and it should look like this for hosts that are not found.
Update
From your comment to this answer it seems that you are not directly connected to the internet if you can't even ping 8.8.8.8.
If you are using a proxy to access the Web, then you also have to configure npm to use it. Use:
npm config set proxy http://example.com:8080
npm config set https-proxy http://example.com:8080
but instead of http://example.com:8080 use what you actually need in your company - ask someone or see how your browser is configured.
To see your proxy configuration in Chrome, see this.
Update 2
If you can access https://registry.npmjs.org/ in your browser but you cannot run ping registry.npmjs.org then it means that your browser must be configured to use a proxy, or other programs than your browser must be restricted from using the internet.
In any case, you should ask someone in your company about it because most likely you either need to use a specific proxy or someone needs to lift the restriction from your npm and allow it to access the network.
The network access can be blocked by a firewall installed on your computer or a router in your network. It's hard to say without knowing the specific configuration in your company.
Update 3
Remove the environment variable "https_proxy" if any or use correct value for "https_proxy"
Solution 2:[2]
use: https://registry.npmjs.org/ Make sure you are trying to connect to:
if there is no error,try to clear cache
npm cache clean --force
then try
npm install
even you have any error
npm config set registry https://registry.npmjs.org/
then try
npm install -g @angular/cli
Solution 3:[3]
I tried many but this worked fine for me.
npm config rm proxy
npm config rm https-proxy
above 2 commands is enough if it doesn't work try this as well.
npm config --global rm proxy
npm config --global rm https-proxy
Solution 4:[4]
First, edit NetworkManager.conf file:
vim /etc/NetworkManager/NetworkManager.conf
Comment this line:
#dns=dnsmasq
Finally
sudo service network-manager restart
sudo service docker restart
Solution 5:[5]
If you are working behind proxy you must set proxy for npm to connect it to repo.
npm config set registry http://registry.npmjs.org/
npm config set proxy http://myusername:[email protected]:8080
npm config set https-proxy http://myusername:[email protected]:8080
npm config set strict-ssl false
set HTTPS_PROXY=http://myusername:[email protected]:8080
set HTTP_PROXY=http://myusername:[email protected]:8080
Note If your password contains special character like @ EX: password : mypwd1@xyz then use %40 in place of @ Ex:
npm config set proxy http://myusername:mypwd1%[email protected]:8080
Solution 6:[6]
npm config set registry https://registry.npmjs.org/
this is the only solution for me.
Solution 7:[7]
If Ubuntu try opening All Settings > Network > Network proxy set the method to automatic and save.
Solution 8:[8]
I had the same issue. The reason was the corporate proxy issue. Solution was to set the proxy setting as @rsp says.
npm config set proxy http://example.com:8080
npm config set https-proxy http://example.com:8080
But later I face the same issue. This time reason was my password contains a special character.
In this command you can’t provide a password with special character
. So solution is to provide percentage encoded special character in the password.
For example # has to provide as %23
Solution 9:[9]
I spent over 5 hours trying to get rid of this message under Windows 8.1. So I would like to share my case and save someones time. I was not behind the proxy... but setting proxy helped to resolve the problem. So I go deep and found that issue was caused by Comodo Firewall... which blocked cmd since I was installing packages too fast (turning off and even closing Firewall did not help, which caused me so long to find the issue... seems like there was some other process of Firewall running in background). You may have same issue with any other firewall/antivirus installed so make sure that cmd is not blocked by them. Good luck!
Solution 10:[10]
in my case it was just an intermittent issues it seems, didn't work for a few tries, then looked at https://registry.npmjs.org (webpage worked fine), tried again, tried again and then it worked.
Solution 11:[11]
For Windows Subsystem Linux:
Restarting my WSL terminal (bash/shell) fixed the issue (it took a few restarts and minutes, however).
use nslookup www.google.com or npm.org to check connectivity.
Solution 12:[12]
First you need to use this command
npm config set registry https://registry.your-registry.npme.io/
This we are doing to set our companies Enterprise registry as our default registry.
You can try other given solutions also.
Solution 13:[13]
Most of the time this issue occurs if you are using the system provided by your organization and you are connected to its vpn. In this case, disconnect from the vpn and then try executing this command.
Solution 14:[14]
npm config rm proxy
npm config rm https-proxy
npm config set registry https://registry.npmjs.org/
These 3 commands one after the other worked for me.
Solution 15:[15]
Running sudo service docker restart was the key for me! Prior to running this command, I was able to access the npm registry using ping and the browser.
Solution 16:[16]
import MaterialCommunityIcon from 'react-native-vector-icons/MaterialCommunityIcons';
call the func at the beginning of the file
MaterialCommunityIcon.loadFont();
Usage:
<MaterialCommunityIcon name="rocket" color="red" size={20} />
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
