39

I'm trying to update the npm (node package manager) using the command:

npm install npm@latest -g

but I'm getting the following error in the command prompt:

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@latest" "-g"

npm ERR! node v6.9.5
npm ERR! npm  v3.10.10
npm ERR! code ECONNREFUSED
npm ERR! errno ECONNREFUSED
npm ERR! syscall connect

npm ERR! Error: connect ECONNREFUSED xxx.xxx.xx.xxx:xxx
npm ERR!     at Object.exports._errnoException (util.js:1022:11)
npm ERR! If you are behind a proxy, please make sure that the
npm ERR! 'proxy' config is set properly.  See: 'npm help config'

does someone know what this really means?
any help would be appreciated.

Nakilon
  • 34,866
  • 14
  • 107
  • 142
NickJS
  • 427
  • 1
  • 4
  • 8

11 Answers11

74

Try:

npm config set proxy null
npm config set https-proxy null
npm config set registry http://registry.npmjs.org/

The first two lines will remove proxy's if there any.

Third line will make npm download from the official package registry.

H Aßdøµ
  • 2,925
  • 4
  • 26
  • 37
Ridd
  • 10,701
  • 3
  • 19
  • 20
14

If you are behind a proxy, please make sure that the npm ERR! 'proxy' config is set properly. See: 'npm help config'

See:

More info:

rsp
  • 107,747
  • 29
  • 201
  • 177
  • This actually worked. I ran these 2 commands and after that I could Install the packages. npm config set proxy http://proxy.company.com:8080 npm config set https-proxy http://proxy.company.com:8080 – NickJS Feb 23 '17 at 14:45
  • npm help config does nothing – KansaiRobot Nov 12 '18 at 09:03
4

I got a similar error when I was using Node JS behind a proxy server. Here's what I had to do to fix it:

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

Just replace "jdoe" and "password123" with your own credentials to access the proxy server. Everything after the @ is the server domain name, or you can enter the exact IP address too. In my case, both addresses were HTTP (not HTTPS).

To confirm the changes, you can type:

npm config list

and your settings should be listed.

You can get the proxy settings (address) from your browser too.

buræquete
  • 14,226
  • 4
  • 44
  • 89
arnold
  • 735
  • 1
  • 7
  • 14
4

I have been trying to fix this issue by

npm config set registry http://registry.npmjs.org/
npm config set proxy http://myproxyblabla:myport
npm config set https-proxy http://myproxyblabla:myport

But it didn't help. The only one solution which worked for me is adding additional fields to host file (C:\Windows\System32\drivers\etc\hosts)

151.101.36.162 registry.npmjs.com
151.101.36.162 registry.npmjs.org

This allowes npm to resolve address to server from which it will download needed files. You can get familiar with closed issue on npm repository where this solution is approved by npm contributors.

Arthur Vasilyev
  • 115
  • 1
  • 1
  • 8
  • cool, its working. npm config set proxy http://myproxyblabla:myport npm config set https-proxy http://myproxyblabla:myport – R.G.Krish Jun 05 '23 at 13:27
3

The problem here is because of proxy. So you need to run the below-mentioned command to remove the proxy and then set the registry from http://registry.npmjs.org/.

    npm config set proxy null
    npm config set https-proxy null
    npm config set registry http://registry.npmjs.org/

And then you can create your first react app by using:

    npx create-react-app your-app-name
Tapas Vashi
  • 231
  • 2
  • 5
3

I had the same error, using Mullvad VPN. It was fixed by enabling IPv6 in Mullvad settings.

roneo.org
  • 291
  • 1
  • 7
2

May be this will help someone in need. I turned to this solution after wasting good 2 hours as my corporate proxy server on work laptop was not getting resolved..!

I removed both proxy and https-proxy from .npmrc file and set only

npm config set registry http://registry.npmjs.org/

Then, I am able to successfully run npm install -g create-react-app

.npmrc file can be found here at C:\Users\<userName>\.npmrc

Cheers! Happy Quarantine Development :p

mfaisalhyder
  • 2,250
  • 3
  • 28
  • 38
1

I had the same problem with my cra and all I had to do was comment out my .npmrc, clean the cache, and run the command npx create-react-app

Ruli
  • 2,592
  • 12
  • 30
  • 40
0

We faced similar issue recently and our requirement was to use public npm registry for one feature and private registry for another feature. So for private registry npm needs to go via proxy but for public registry we don't need proxy so we created .npmrc file inside our project and added two config variables:

registry and noproxy where noproxy points to the public domain of the registry. This will make sure to skip the proxy config from your global npmrc file.

rootkonda
  • 1,700
  • 1
  • 6
  • 11
-1

We happened to run into this error message because in our setup, the Maven Nexus NPM Repository ran on the same machine and we therefore first used http://localhost/xyz/ as the NPM repository URL.

For whatever reason, localhost was treated as a system-type NPM registry, causing errors.

Changing the NPM repository URL configuration to the computer's hostname, e.g. http://mycomputer.company.intra/xyz/ fixed the issue.

Abdull
  • 26,371
  • 26
  • 130
  • 172
-2

What fixed it for me, was to enable SMB 1.0 in Window's Control Panel on my development PC as follows:

Control Panel > Programs and Features > Turn Windows features on or off > SMB 1.0

enter image description here

Greg Trevellick
  • 1,361
  • 1
  • 16
  • 26