gpt4 book ai didi

angular - 更新 Angular 7 时出错 -> Angular 8

转载 作者:行者123 更新时间:2023-12-04 17:35:56 32 4
gpt4 key购买 nike

一个月前,我开始了一个 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我发现:

"Once you and all of your dependencies have updated to RxJS 6, remove rxjs-compat."

我应该在 rxjs^6 上。我需要 rxjs-compat 才能使用由 https://github.com/swagger-api/swagger-codegen 生成的 swagger 客户端 .我试图从 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 客户端

最佳答案

使用 ngrx 升级 angular 的步骤

卸载ngrx包

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

由于ngrx包不可用,迁移angular核心包时会触发错误

解决问题重新安装 ngrx 包

运行命令 ng update @angular/core --from 7 --to 8 --migrate-only

完成 Angular 升级

关于angular - 更新 Angular 7 时出错 -> Angular 8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56575964/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com