无法启动Angular 5项目:npm ERR!代码ECONNRESET

时间:2018-02-24 10:30:50

标签: node.js angular npm

两天后我试图在Angular 5中启动一个新项目,看起来我有一些设置错误阻止我的项目创建node_modules文件夹,这里是我尝试不同命令时遇到的错误列表(我也用sudo尝试了所有这些)。 我已经尝试过Stackoverflow similar issue from 2013这个了 Github Error during npm install - ECONNRESET #9418并且没有任何作用。我认为它与我的堆栈的不同版本不兼容可能我应该使用节点版本管理器 Github Node version manager

这是我的堆栈实际版本:

npm:5.6.0(奇怪,即使我做了npm -v命令我有错误消息npm update check failed ) 节点v8.9.4

这是我的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"
  ]
  }
}

这是我的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"
  }
}

首先,当我运行ng new my-new-project时,它会正常工作,直到Ì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'

然后我尝试了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'

2 个答案:

答案 0 :(得分:0)

运行这些命令,然后再试一次: -

npm config rm proxy
npm config rm https-proxy

答案 1 :(得分:0)

我几次遇到相同的问题,并尝试了一下,并且有效-

  1. 删除创建的不完整项目目录,该目录以git bash上的以下错误结尾-

npm ERR!代码ECONNRESET npm ERR!网络中止 npm ERR!网络这是与网络连接有关的问题。 npm ERR!网络在大多数情况下,您位于代理服务器后面或网络设置不正确。 npm ERR!网络 npm ERR!网络如果您是代理人,请确保 npm ERR!网络“代理”配置正确设置。请参阅:“ npm帮助配置”

npm ERR!可以在以下位置找到此运行的完整日志: npm ERR! C:\ Users \ SHWETA \ AppData \ Local \ npm-cache_logs \ 2020-11-24T14_05_44_640Z-debug.log ×软件包安装失败,请参见上文。 原理图工作流程失败。见上文。

  1. 运行这两个命令-

(i)npm config rm代理

(ii)npm config rm https-proxy

  1. 使用与之前相同的命令再次创建角度项目-

ng新的angularapp

它就像一种魅力!

相关问题