web-dev-qa-db-ja.com

Angular 5を6にアップグレードすると、互換性のないピア依存関係が発生します(ng update @ angular / coreを使用)

Angularアプリをv5からv6に更新しようとしています このガイド

これらすべてのコマンドを正常に実行しました。

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

問題は、このコマンドを実行するとエラーが発生することです。

ng update @angular/core
                  Package "@angular/flex-layout" has an incompatible peer dependency to "rxjs" (requires "^5.5.0", would install "6.2.0").
                  Package "@angular/compiler-cli" has an incompatible peer dependency to "TypeScript" (requires ">=2.7.2 <2.8", would install "2.6.2")
Incompatible peer dependencies found. See above.

私はこれをどのように扱うかわからない。アプリを壊さないように自分で試してみたいとは思わない。

誰かが何をすべきかアドバイスしてもらえますか?

私の現在の依存関係は次のとおりです。

{
 ....
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^5.2.10",
    "@angular/cdk": "^5.2.5",
    "@angular/common": "^5.2.10",
    "@angular/compiler": "^5.2.10",
    "@angular/core": "^5.2.10",
    "@angular/flex-layout": "^5.0.0-beta.14",
    "@angular/forms": "^5.2.10",
    "@angular/http": "^5.2.10",
    "@angular/material": "^5.2.5",
    "@angular/platform-browser": "^5.2.10",
    "@angular/platform-browser-dynamic": "^5.2.10",
    "@angular/router": "^5.2.10",
    "@ngx-translate/core": "^9.1.1",
    "@ngx-translate/http-loader": "^3.0.1",
    "core-js": "^2.5.5",
    "hammerjs": "^2.0.8",
    "primeng": "^5.2.4",
    "rxjs": "^5.5.11",
    "zone.js": "^0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.6.3",
    "@angular/cli": "^6.0.3",
    "@angular/compiler-cli": "^5.2.11",
    "@angular/language-service": "^5.2.10",
    "@types/jasmine": "~2.8.3",
    "@types/jasminewd2": "~2.0.2",
    "@types/node": "^6.0.106",
    "codelyzer": "^4.3.0",
    "jasmine-core": "~2.8.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "^2.0.2",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "^1.2.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "^5.3.2",
    "ts-node": "~4.1.0",
    "tslint": "~5.9.1",
    "TypeScript": "~2.6.2"
  }
}
28
Ahmed Elkoussy

これが他の人の助けになることを願っています。最終的に、いくつかのangularパッケージを手動で更新することで問題を解決できます(npmを使用)

npm i @angular/cdk@6 @angular/compiler-cli@6 @angular/material@6 rxjs@6 --save

その後、ng updateコマンドが機能する可能性があります(いくつかの警告がありますが、少なくともng update @ angular/coreを渡しました)

ng update @angular/core
    Updating package.json with dependency @angular/language-service @ "6.0.3" (was "5.2.10")...
    Updating package.json with dependency @angular/animations @ "6.0.3" (was "5.2.10")...
    Updating package.json with dependency @angular/forms @ "6.0.3" (was "5.2.10")...
    Updating package.json with dependency @angular/common @ "6.0.3" (was "5.2.10")...
    Updating package.json with dependency @angular/compiler @ "6.0.3" (was "5.2.10")...
    Updating package.json with dependency @angular/core @ "6.0.3" (was "5.2.10")...
    Updating package.json with dependency @angular/router @ "6.0.3" (was "5.2.10")...
    Updating package.json with dependency @angular/platform-browser-dynamic @ "6.0.3" (was "5.2.10")...
    Updating package.json with dependency @angular/platform-browser @ "6.0.3" (was "5.2.10")...
    Updating package.json with dependency @angular/http @ "6.0.3" (was "5.2.10")...
UPDATE package.json (1587 bytes)
npm WARN @angular/[email protected] requires a peer of TypeScript@>=2.7.2 <2.8 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/[email protected] requires a peer of @angular/cdk@^5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/[email protected] requires a peer of @angular/core@^5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/[email protected] requires a peer of @angular/common@^5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/[email protected] requires a peer of rxjs@^5.5.0 but none is installed. You must install peer dependencies yourself.
npm WARN @ngtools/[email protected] requires a peer of TypeScript@~2.4.0 || ~2.5.0 || ~2.6.0 || ~2.7.0 but none is installed. You must install peer dependencies yourself.
npm WARN @ngx-translate/[email protected] requires a peer of @ngx-translate/core@>=10.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of TypeScript@>=2.4.2 <2.8 but none is installed. You must install peer dependencies yourself.

updated 10 packages in 57.253s
17
Ahmed Elkoussy

これを回避するには、--forceフラグを追加します。

ng update @angular/core --force
30
Rust

次のような強制更新を行った後、問題は解決しました。

ng update --all --force

基本的に、すべての依存関係チェックを回避/無視し、該当するすべてのパッケージを更新します。一般的には推奨されていませんが、他の提案が機能していないように思えたため、この方法で更新を行う必要がありました。

10
Sen

以下を使用して、互換性のないピアに関するメッセージを回避できました。

ng update --all

更新が必要なすべてのパッケージを更新しました。

2
lilabnersgal