相关文章推荐
低调的蛋挞  ·  mysql ...·  1 年前    · 
好帅的苦咖啡  ·  从pandas ...·  1 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

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.

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.

I've tried removing the proxy but it didn't work, setting them to null fixed the issue :/ – Pezhvak Apr 16 at 5:30

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

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

  • How to setup Node.js and Npm behind a corporate web proxy
  • This actually worked. I ran these 2 commands and after that I could Install the packages. npm config set proxy proxy.company.com:8080 npm config set https-proxy proxy.company.com:8080 – NickJS Feb 23, 2017 at 14:45

    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.

    cool, its working. npm config set proxy myproxyblabla:myport npm config set https-proxy myproxyblabla:myport – R.G.Krish Jun 5 at 13:27

    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.

    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
    

    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

    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.

    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.

    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

    Thanks for contributing an answer to Stack Overflow!

    • Please be sure to answer the question. Provide details and share your research!

    But avoid

    • Asking for help, clarification, or responding to other answers.
    • Making statements based on opinion; back them up with references or personal experience.

    To learn more, see our tips on writing great answers.