npm ERR! Error: connect ECONNREFUSED

后端 未结 5 1558
深忆病人
深忆病人 2020-11-30 06:36

I\'m trying to update the npm (node package manager) using the command: npm install npm@latest -g but I\', getting the following error in the command prompt:

does

相关标签:
5条回答
  • 2020-11-30 07:11

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

    See:

    • https://docs.npmjs.com/cli/config

    More info:

    • How to setup Node.js and Npm behind a corporate web proxy
    0 讨论(0)
  • 2020-11-30 07:14

    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

    0 讨论(0)
  • 2020-11-30 07:29

    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.

    0 讨论(0)
  • 2020-11-30 07:34

    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.

    0 讨论(0)
  • 2020-11-30 07:38

    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.

    0 讨论(0)
提交回复
热议问题