更新Angular 7-> Angular 8时出错

时间:2019-06-13 08:03:09

标签: angular angular-material angular7 swagger-codegen angular8

一个月前,我开始了一个Angular 7项目。现在,我需要将Angular Material包含到项目中并npm i。它最近在版本8中发布,该版本似乎与Angular 7不兼容。

所以我开始更新Angular 7→Angular 8:ng update @angular/cli @angular/core。这给了我一个错误:

$ng update @angular/cli @angular/core

Package "@ngrx/core" has an incompatible peer dependency to "rxjs" (requires "^5.0.0-beta.12", would install "6.5.2").

Incompatible peer dependencies found. See above.

在本指南https://update.angular.io/#7.0:8.0中,我发现:

  

“一旦您和所有依赖项都更新为RxJS 6,请删除   rxjs-compat。”

我应该在rxjs ^ 6上。我需要rxjs-compat才能使用由https://github.com/swagger-api/swagger-codegen生成的swagger client。我试图从package.json中删除"rxjs-compat": "^6.5.2",但是没有运气。

package.json:

{
  "name": "fem",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "$(npm bin)/cypress open",
    "e2e-protractor": "ng e2e",
    "swagger-generate": "swagger-codegen generate -i ./swagger.json -l typescript-angular -o ./src/swagger-client"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^7.2.15",
    "@angular/cdk": "^8.0.1",
    "@angular/common": "~7.2.0",
    "@angular/compiler": "~7.2.0",
    "@angular/core": "~7.2.0",
    "@angular/forms": "~7.2.0",
    "@angular/material": "^8.0.1",
    "@angular/platform-browser": "~7.2.0",
    "@angular/platform-browser-dynamic": "~7.2.0",
    "@angular/router": "~7.2.0",
    "@ngrx/core": "^1.2.0",
    "@ngrx/effects": "^7.4.0",
    "@ngrx/entity": "^7.4.0",
    "@ngrx/router-store": "^7.4.0",
    "@ngrx/schematics": "^7.4.0",
    "@ngrx/store": "^7.4.0",
    "@ngrx/store-devtools": "^7.4.0",
    "angular-in-memory-web-api": "^0.8.0",
    "classlist.js": "^1.1.20150312",
    "core-js": "^2.6.9",
    "date-fns": "^1.30.1",
    "formdata-polyfill": "^3.0.18",
    "hammerjs": "^2.0.8",
    "rxjs": "~6.3.3",
    "rxjs-compat": "^6.5.2",
    "tslib": "^1.9.0",
    "uuid": "^3.3.2",
    "web-animations-js": "^2.3.1",
    "zone.js": "~0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.13.0",
    "@angular/cli": "~7.3.9",
    "@angular/compiler-cli": "~7.2.0",
    "@angular/language-service": "~7.2.0",
    "@types/date-fns": "^2.6.0",
    "@types/jasmine": "~2.8.8",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~8.9.4",
    "@types/uuid": "^3.4.4",
    "codelyzer": "~4.5.0",
    "cypress": "^3.3.1",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~4.0.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~1.1.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.4.0",
    "ts-node": "~7.0.0",
    "tslint": "~5.11.0",
    "typescript": "~3.2.2"
  }
}

所以我的目标是:

  1. 能够在项目中使用Angular Material v8
  2. 更新为Angular v8
  3. 继续使用生成的Swagger客户端

2 个答案:

答案 0 :(得分:0)

您需要放弃npm的直接操作以升级Angular,并使用新的Angular Schematics来自动完成所有必需的工作。

改为使用ng update并从那里更新每个包,您可以使用npm更新其他库,但是Angular及其库的新范例是通过Schematics进行的。

增强其功能并开发自己的代码生成器;)

答案 1 :(得分:0)

使用ngrx升级角度

卸载ngrx软件包

运行命令ng update @ angular / cli @ angular / core

由于ngrx软件包不可用,在迁移有角度的核心软件包时将触发错误

要解决问题,请重新安装ngrx软件包

运行命令ng update @ angular / core-从7-到8-仅迁移

完成角度升级