无法更新角度版本

时间:2019-09-20 07:53:02

标签: javascript node.js json angular typescript

我正在尝试升级我的角度应用程序。我的角度应用程序版本为Basic Apps 4.2.4。 我正在使用Angular Update Guide中给出的步骤。

根据指南,我必须运行以下

npm install -g @angular/cli
npm install @angular/cli
ng update @angular/cli

但是当我尝试执行命令

ng update @angular/cli

它给我一个错误的说法

Error: Cannot update safely because packages have conflicting dependencies. Package @angular/core would need to match both versions "7.2.15" and "8.2.7, which are not compatible.
Cannot update safely because packages have conflicting dependencies. Package @angular/core would need to match both versions "7.2.15" and "8.2.7, which are not compatible.

这就是我的package.json的样子

{
  "name": "stellar",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^4.2.4",
    "@angular/common": "^4.2.4",
    "@angular/compiler": "^4.2.4",
    "@angular/core": "^4.2.4",
    "@angular/forms": "^4.2.4",
    "@angular/http": "^4.2.4",
    "@angular/platform-browser": "^4.2.4",
    "@angular/platform-browser-dynamic": "^4.2.4",
    "@angular/router": "^4.2.4",
    "angular2-jwt": "^0.2.3",
    "chart.js": "^2.7.2",
    "core-js": "^2.4.1",
    "jquery": "^3.3.1",
    "ng2-archwizard": "^2.1.0",
    "ng2-charts": "^1.6.0",
    "ng2-toastr": "^4.1.2",
    "ng2-validation": "^4.2.0",
    "ngx-bootstrap": "^2.0.5",
    "npm": "^6.2.0",
    "rxjs": "^5.4.2",
    "slick-carousel": "^1.8.1",
    "zone.js": "^0.8.14"
  },
  "devDependencies": {
    "@angular/cli": "^1.7.4",
    "@angular/compiler-cli": "^4.2.4",
    "@angular/language-service": "^4.2.4",
    "@types/c3": "^0.6.0",
    "@types/jasmine": "~2.5.53",
    "@types/jasminewd2": "~2.0.2",
    "@types/node": "~6.0.60",
    "c3": "^0.6.2",
    "codelyzer": "~3.2.0",
    "jasmine-core": "~2.6.2",
    "jasmine-spec-reporter": "~4.1.0",
    "karma": "^2.0.5",
    "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.4.0",
    "ts-node": "~3.2.0",
    "tslint": "~5.7.0",
    "typescript": "~2.3.3"
  }
}

有人可以帮忙排序吗

2 个答案:

答案 0 :(得分:3)

我认为您可以遵循此tutorial

或者手动更新您的角度包版本,如下所示

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "module": "esnext", // add this line
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "importHelpers": true,
    "target": "es2015",// add this line
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2018",
      "dom"
    ]
  }
}

像这样更新您的tsconfig.json

{{1}}

更新:

安装rxjs-compact解决问题

答案 1 :(得分:0)

遵循此tutorial或运行以下命令:

#Install npm-check-updates
$ npm i -g npm-check-updates
 
#Run npm-check-updates with -u, will upgrade package.json
$ ncu -u
 
#Install updated packages
$ npm install

#Then run
npm install typescript@3.5.3