0

Since two days I am trying to start a new project in Angular 5 and it look like I have some settings errors that stops my project to create the node_modules folder, here are the list of errors I have got when I tried differents commands (I tried all of them with sudo also). I already tried this Stackoverflow similar issue from 2013 and this Github Error during npm install - ECONNRESET #9418 and nothing works..I suppose it's about incompatibility with differents versions of my stack maybe should I use Node Version Manager Github Node version manager

Here are my stack actual version:

npm: 5.6.0 (strange even when I did a npm -v command I have error message npm update check failed) node v8.9.4

here's my tsconfig.json:

{
"compileOnSave": false,
"compilerOptions": {
  "outDir": "./dist/out-tsc",
  "sourceMap": true,
  "declaration": false,
  "moduleResolution": "node",
  "emitDecoratorMetadata": true,
  "experimentalDecorators": true,
  "target": "es5",
  "typeRoots": [
  "node_modules/@types"
  ],
  "lib": [
    "es2017",
    "dom"
  ]
  }
}

here's my package.json:

{
"name": "todo-list",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build --prod",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^5.0.0",
"@angular/common": "^5.0.0",
"@angular/compiler": "^5.0.0",
"@angular/core": "^5.0.0",
"@angular/forms": "^5.0.0",
"@angular/http": "^5.0.0",
"@angular/platform-browser": "^5.0.0",
"@angular/platform-browser-dynamic": "^5.0.0",
"@angular/router": "^5.0.0",
"core-js": "^2.4.1",
"rxjs": "^5.5.2",
"zone.js": "^0.8.14"
},
"devDependencies": {
  "@angular/cli": "1.6.3",
  "@angular/compiler-cli": "^5.0.0",
  "@angular/language-service": "^5.0.0",
  "@types/jasmine": "~2.5.53",
  "@types/jasminewd2": "~2.0.2",
  "@types/node": "~6.0.60",
  "codelyzer": "^4.0.1",
  "jasmine-core": "~2.6.2",
  "jasmine-spec-reporter": "~4.1.0",
  "karma": "~1.7.0",
  "karma-chrome-launcher": "~2.1.1",
  "karma-cli": "~1.0.1",
  "karma-coverage-istanbul-reporter": "^1.2.1",
  "karma-jasmine": "~1.1.0",
  "karma-jasmine-html-reporter": "^0.2.2",
  "protractor": "~5.1.2",
  "ts-node": "~3.2.0",
  "tslint": "~5.7.0",
  "typescript": "~2.4.2"
  }
}

First when I run ng new my-new-project it works fine until Ìnstalling packages for tooling via npm:

npm ERR! code ECONNRESET
npm ERR! errno ECONNRESET
npm ERR! network request to http://registry.npmjs.org/@angular%2fcore 
failed, reason: read ECONNRESET
npm ERR! network This is a problem 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'

Then I tried a npm install -g typescript:

npm ERR! code ECONNRESET
npm ERR! errno ECONNRESET
npm ERR! network request to http://registry.npmjs.org/typescript failed, reason: read ECONNRESET
npm ERR! network This is a problem 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'
Emile Cantero
  • 1,943
  • 3
  • 22
  • 47
  • You could try to use [yarn](https://yarnpkg.com/en/) instead of npm, because it's more robust against network errors. And `ECONNRESET` can be caused by an instable internet connection. – cyr_x Feb 24 '18 at 10:55
  • My network seems pretty stable got 70mbits down and 4mbits up I tried many speedtest and seems to work perfectly – Emile Cantero Feb 24 '18 at 11:04
  • With instable i meant a high packet loss, you could test it with `ping www.google.com -n 30` on the console for example. Because npm tends to report the ECONNRESET if your connection has a high packet loss. – cyr_x Feb 24 '18 at 11:07
  • @cyrix when I run a ping www.google.com here's the result: `--- www.google.com ping statistics --- 44 packets transmitted, 44 packets received, 0.0% packet loss round-trip min/avg/max/stddev = 24.564/30.287/60.895/10.326 ms` – Emile Cantero Feb 24 '18 at 11:19
  • 1
    Okay so your connection looks stable, did you try yarn yet ? I had the error quite often with `npm` and it never happened using yarn, also yarn is much faster. Also what's your OS? – cyr_x Feb 24 '18 at 11:20
  • @cyrix I never used Yarn before...should I have to ununstall npm first? – Emile Cantero Feb 24 '18 at 11:22
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/165751/discussion-between-cyrix-and-emile-cantero). – cyr_x Feb 24 '18 at 11:22

2 Answers2

0

run these commands and then try again :-

npm config rm proxy
npm config rm https-proxy
ncoder
  • 151
  • 1
  • 8
0

I was getting the same problem several times and tried this and it worked-

  1. delete the incomplete project directory created which ended with follwing error on git bash-

npm ERR! code ECONNRESET npm ERR! network aborted npm ERR! network This is a problem 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! A complete log of this run can be found in: npm ERR! C:\Users\SHWETA\AppData\Local\npm-cache_logs\2020-11-24T14_05_44_640Z-debug.log × Package install failed, see above. The Schematic workflow failed. See above.

  1. Ran these 2 commands-

(i) npm config rm proxy

(ii) npm config rm https-proxy

  1. created the angular project again with same command as before-

ng new angularapp

It works like a charm!