39

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.

Bhuvaneshwari K
  • 415
  • 1
  • 4
  • 13

19 Answers19

51

Things to try:

  1. make sure you have internet connection: ping 8.8.8.8
  2. make sure you have DNS resolver working: ping www.google.com
  3. make sure you can access registry.npmjs.org: ping registry.npmjs.org
  4. 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"

Valdi_Bo
  • 30,023
  • 4
  • 23
  • 41
rsp
  • 107,747
  • 29
  • 201
  • 177
  • 1.Ping statistics for 8.8.8.8 Packets: Sent = 4, Received = 0, Lost = 4 (100% loss), 2.Ping request could not find host www.google.com. Please check the name and try again. 3. same as 2nd 4. getting some data – Bhuvaneshwari K Sep 20 '16 at 11:48
  • network tunneling socket could not be established, cause=connect ECONNR. This is most likely not a problem with npm itself. Network and is related to network connectivity.In most cases you are behind a proxy or have bad network setting.If you are behind a proxy, please make sure that the npm ERR! network 'proxy' config is set properly. See: 'npm help config' – Bhuvaneshwari K Sep 20 '16 at 12:45
  • Got the above error, even after trying the command you mentioned @rsp – Bhuvaneshwari K Sep 20 '16 at 12:46
  • @BhuvanaK But did you substitute the `example.com` with your actual company proxy? Did you find it in your browser's settings or asked someone in your company about what the server and port should be? See Update 2 to my answer. – rsp Sep 20 '16 at 13:06
  • Yes Now working fine. Mismatch happen. In proxy, entered port as 8080. In npm, tried with 8000. Now it's working fine. Thank you very much. – Bhuvaneshwari K Sep 20 '16 at 13:17
  • @BhuvanaK That's good to hear. You can accept the answer so others can see that the problem is solved. Here is [how to accept the answer properly](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work/5235#5235). – rsp Sep 21 '16 at 07:39
  • If you're connecting to "registry.npmjs.org registry.npmjs.org:443" try running this "npm config set registry http://registry.npmjs.org/" found the answer here >> https://github.com/npm/npm/issues/9630 – user3714598 Sep 02 '17 at 15:50
21

use: https://registry.npmjs.org/ Make sure you are trying to connect to:

registry.npmjs.org

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
aioobe
  • 413,195
  • 112
  • 811
  • 826
malith vitha
  • 473
  • 4
  • 4
17

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
Nagendra Reddy
  • 531
  • 5
  • 7
10

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
jansanchez
  • 1,179
  • 8
  • 6
  • tankyou @jansanchez it help me alot – manoj Jun 01 '17 at 10:06
  • THIS. Had the exact same issue @bhuvana-k mentioned while being connected directly to the internet. Connecting through the web browser would work while pulling dependencies via `npm` would fail - disabling `dnsmasq` helped - thanks! – Mike Floyd Jul 12 '18 at 09:05
9

You can use this command

npm config delete proxy

It happens because formidable is prone to severity vulnerability. So, you need to override that by running the above command.

Jayson
  • 1,105
  • 7
  • 25
Nagnath Bhat
  • 106
  • 1
  • 2
  • Hi! according to the comment on abdulbarik's [answer](https://stackoverflow.com/a/39593195/1008011), the asker has already tried what you have suggested and it didn't solve the issue. – chornge Jan 10 '19 at 07:01
3

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:mypassword@proxy.somecompany.com:8080
npm config set https-proxy http://myusername:mypassword@proxy.somecompany.com:8080
npm config set strict-ssl false
set HTTPS_PROXY=http://myusername:mypassword@proxy.somecompany.com:8080
set HTTP_PROXY=http://myusername:mypassword@proxy.somecompany.com: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%40xyz@proxy.somecompany.com:8080
Vikash Kumar
  • 1,096
  • 11
  • 10
  • 1
    For me It worl like --- I set npm config set proxy http://proxy.ops.xxx-yyy.zzz:8080/ and npm config set https_proxy http://proxy.ops.xxx-yyy.zzz:8080/ . here " http://proxy.ops.xxx-yyy.zzz:8080/" will be your company provided proxy and it work like a charm – AKS Dec 23 '19 at 19:35
2
npm config set registry https://registry.npmjs.org/

this is the only solution for me.

myeongkil kim
  • 2,465
  • 4
  • 16
  • 22
  • Is it possible to briefly explain what part of the actual question is missing because it is wrong, why the operation command was able to solve the problem, and what the actual result is? – myeongkil kim Dec 21 '20 at 07:16
1

In my case very alike error (ENOTFOUND registry.npmjs.org) was fixed by adding --no-bin-links to npm install command.

Wierd but might help someone.

Nomik
  • 170
  • 2
  • 5
0

If Ubuntu try opening All Settings > Network > Network proxy set the method to automatic and save.

0

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

https://www.w3schools.com/tags/ref_urlencode.asp

Jomy John
  • 6,308
  • 4
  • 28
  • 32
0

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!

Developer
  • 188
  • 1
  • 9
0

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.

localhostdotdev
  • 1,795
  • 16
  • 21
0

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.

Neoraptor
  • 951
  • 1
  • 7
  • 13
0

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.

Su So
  • 168
  • 1
  • 3
  • 12
0

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.

jaihind
  • 1,090
  • 1
  • 8
  • 9
0

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.

daTo
  • 1
  • 1
  • It's better to prepent CLI commands with some introductory words. The commands themselves are better formatted as code blocks – Ruslan Zhomir Nov 02 '21 at 22:45
0

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.

Tyler2P
  • 2,324
  • 26
  • 22
  • 31
0

use this command it will work npm config set registry "http://registry.npmjs.org/"

  • your answer has english grammar errors, and does not explain clearly how to fix the issue. Please, when you answer a question, take your time into creating an answer that can be helpful. – Ion Utale Jul 04 '23 at 15:13
0

In my case the issue was with DNS not able to resolve IP against a particular domain. Pointing to 8.8.8.8 google DNS resolved the issue.

suthar_arun
  • 81
  • 1
  • 5