[node.js] npm not working - "read ECONNRESET"

I'm having a problem with npm, I cant install anything. Here is the error messages:

C:\Windows\system32>npm install -g yo
npm http GET https://registry.npmjs.org/yo
npm http GET https://registry.npmjs.org/yo
npm http GET https://registry.npmjs.org/yo
npm ERR! network read ECONNRESET
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 settin
gs.
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! System Windows_NT 6.2.9200
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nod
ejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "yo"
npm ERR! cwd C:\Windows\system32
npm ERR! node -v v0.10.17
npm ERR! npm -v 1.3.8
npm ERR! syscall read
npm ERR! code ECONNRESET
npm ERR! errno ECONNRESET
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     C:\Windows\system32\npm-debug.log
npm ERR! not ok code 0

Any idea why is this? Here are my network settings and it seems I dont have any proxy configured. I also disabled all the firewalls.

enter image description here

This question is related to node.js npm

The answer is


use

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

so that npm requests for http url instead of https.

and then try the same npm install command


npm config set https-proxy "http://username:password@proxy-url:proxy-port" worked for me


Remove yarn.lock , package-lock.json, node_modules

and then

npm install -f 

Worked for me


This is what worked for me:

proxy = http://1.1.1.1:3128/
https_proxy = http://1.1.1.1:3128/
strict-ssl = false
ca = null
registry = http://registry.npmjs.org/

Answer found here: https://fak3r.com/2015/07/31/howto-use-npm-behind-a-corporate-proxy/


Remove your proxy settings at home and switch on at Office networks, This may be irritating, But It worked for me:

npm config set proxy http://xxx.xxx.xxx.4:8080   
npm config set https-proxy http://xxx.xxx.xxx.4:8080

and

npm config rm proxy   
npm config rm https-proxy

I found "npm config edit" to be more useful to update the entries for https-proxy, proxy, registry

I did something like this

  • npm config list
  • npm config edit (opens in vi)
  • Edit or set the config entries for https-proxy, proxy, registry
  • npm install

I've tried almost all methods posted here and in other pages but didn't work. Here are the commands I've executed in order, which I encourage you to try because it worked for many people (but not me):

  • npm config rm proxy
  • npm config rm https-proxy
  • npm config set https-proxy https://username:[email protected]:6050
  • npm config set proxy http://username:[email protected]:6050
  • npm config set registry http://registry.npmjs.org/

And then trying to install the package npm install -g express, but it failed.

However, when I tried to run npm install npm@latest -g it miraculously executed and installed fine!
Then running npm install -g express again worked perfectly fine too.

TL;DR: updating npm to the latest version solved the issue (currently 6.0.1)


You may also need to specify the proxy server/port, in some environments the system settings for proxy are not enough for npm to work.

    npm config set proxy "http://your-proxy.com:80"

The three thing to make npm working well inside the proxy network .

This set npm registry , By default it may take https.

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

Second is two set proxy in your system . If your organization use proxy or you.

npm config set proxy "http://username:password@proxy-url:proxy-port"

npm config set https-proxy "http://username:password@proxy-url:proxy-port"

You can also check if they are set or not , by

npm config get https-proxy

for all values.


This can be caused by installing anything with npm using sudo -- this causes the files in the cache to be owned by root, resulting in this problem. You can fix it by running:

sudo rm -rf ~/.npm

to remove the cache. Then try whatever you were doing again, making sure you never use sudo along with npm (or the problem may come back).

Lots more information: npm throws error without sudo


This is an old question, but anyway.

I had this issue, when I was trying to deploy to heroku, and the fix that worked for me was to update the npm version that was used. I had version 2.x.x and I updated to 3.x.x


If you're using Windows you should follow up on Advanced System Settings to check the env vars declared over there, you should notice that the proxy configuration may lie within environment variables, like in the picture below:

Windows env vars

So if your proxy server is not available or is blocking traffic from npm you might notice the aforementioned error in this topic. Maybe you don't need any proxy at all, in this case, just remove this HTTP_PROXY env variables.

I had turned all proxy configurations off in my Windows and npm settings, however, npm was still getting timeout and connection errors while downloading resources, then I figured out there was still a proxy configuration left on env variables, which was causing all the trouble.


I had the same problem when trying to run npm on system emulated in Oracle VirtualBox. I resolved it by adding Google DNS address in Network Adapter properties.

Network Adapter properties > IPv4 properties > Preferred DNS address: 8.8.8.8.


npm config rm proxy

npm config rm https-proxy

works for me!


I had the same issue but none of these solutions worked correctly. Finally, I have installed packages via yarn, which is npm-compatible. As per official website:

Migrating from npm should be a fairly easy process for most users. Yarn can consume the same package.json format as npm, and can install any package from the npm registry.

Just install the yarn and then then, run the install by using the following command, the equivalent to npm install in yarn:

yarn install

Read more at—Yarn: Migrating from npm.


You may want to check your NPM proxy settings and perhaps remove it.

npm config get proxy
npm config rm proxy
npm config rm https-proxy

One might expect a fresh install of NodeJS+NPM would not have a proxy configured. Strangely enough, mine did come with a proxy defined, pointing to an IP and port 3128. Removing the proxy did the trick.


At work, i had to load up my browser and browse a webpage (which authenticates me to our web-filter). Then I retried the command and it worked successfully.


I did not want to switch to http for the registry, what worked for me was downgrading from the latest Node version to the LTS version (as of now, 6.x).


You may also encounter this error if you have a saved bearer token that is now invalid. I've encountered this when using a private repo where the accounts were wiped and reset, invalidating the tokens. Although your repo may not require authentication, if you have a token from a previous login it will be passed and if it's invalid your connection will be closed.

You can resolve this by either logging in again with the new user name and password, or presumably by simply logging out via npm.


In case this helps anyone who was in my situation: I recently installed Fiddler, which (unbeknownst to me) added a network proxy through 127.0.0.1:8866. I went into my Ubuntu network settings, clicked into the "Network Proxy" settings, and disabled it, and then all was back to normal.

So in general, check to make sure you haven't got a network proxy set up due to a side-effect of something else you were doing.


Restarting my PC made it worked.


Just in case...simply trying one more time worked for me. It could just be a temporary connection issue.


Please use this

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


Solution 1:

MAC + LINUX

run this command with sudo

sudo npm install -g yo

Windows

run cmd as administrator and then run this command again

Solution 2:

run this command and then try

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

I had the problem with npm throwing this error.

So basically whenever error was thrown i either used manual install
from git or waited and installed specified version like:

npm install resolve@^1.1.6

when running alone:

npm install resolve

didn't worked.

I updated node.js from 7 to 8 and npm install goes smoothly.

I think that maybe the version 7 caused this problem since @luschn downgraded to 6 so he didn't use 7 too.

Maybe the registry itself is returning errors without showing problems on their status pages because after some time i could install this one breaking package and then proceed with npm install to install the rest.


I had the same issue in windows while installing any package from npm. Fixed that with - ** open command prompt as administrator and run these 3 commands **/

1. npm config rm proxy

2. npm config rm https-proxy

3. npm install npm@latest -g

FOR MAC / LINUX
1. sudo npm config rm proxy

2. sudo npm config rm https-proxy

3. sudo npm install npm@latest -g

Basically this was version isuue with npm . Please check its worrking


Our company firewall will stop installing node hence connect to the personal network and install, it worked for me.


I had the same problem on my local home network without proxy. Other answers in this thread didn't work for me. What I ended up doing was using yarn which can be used interchangeably with npm:

yarn add

To this day I don't know why my npm still don't work. I know for sure that it's a problem with my Wi-Fi, because when I connect to LTE internet broadcasted from my smartphone npm install works again. It has probably something to do with router settings (problems started when I upgraded my internet speed and ISP worker replaced my old router with a new one).


Examples related to node.js

Hide Signs that Meteor.js was Used Querying date field in MongoDB with Mongoose SyntaxError: Cannot use import statement outside a module Server Discovery And Monitoring engine is deprecated How to fix ReferenceError: primordials is not defined in node UnhandledPromiseRejectionWarning: This error originated either by throwing inside of an async function without a catch block dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.62.dylib error running php after installing node with brew on Mac internal/modules/cjs/loader.js:582 throw err DeprecationWarning: Buffer() is deprecated due to security and usability issues when I move my script to another server Please run `npm cache clean`

Examples related to npm

What does 'x packages are looking for funding' mean when running `npm install`? error: This is probably not a problem with npm. There is likely additional logging output above Module not found: Error: Can't resolve 'core-js/es6' Browserslist: caniuse-lite is outdated. Please run next command `npm update caniuse-lite browserslist` ERROR in The Angular Compiler requires TypeScript >=3.1.1 and <3.2.0 but 3.2.1 was found instead DeprecationWarning: Buffer() is deprecated due to security and usability issues when I move my script to another server Please run `npm cache clean` What exactly is the 'react-scripts start' command? On npm install: Unhandled rejection Error: EACCES: permission denied Difference between npx and npm?