我正在尝试在this guide之后将我的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.
我不知道如何处理这个&amp;我不想自己尝试以避免破坏应用程序。
有人可以建议做什么吗?
我目前的依赖关系如下:
{
....
},
"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"
}
}
答案 0 :(得分:21)
解决此问题的方法是添加--force
标志。
ng update @angular/core --force
答案 1 :(得分:14)
希望这会帮助别人,我终于可以通过手动更新一些角度包来解决问题(使用npm)
npm i @angular/cdk@6 @angular/compiler-cli@6 @angular/material@6 rxjs@6 --save
之后ng更新命令可以工作(有一些警告,但至少我们通过了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/compiler-cli@6.0.3 requires a peer of typescript@>=2.7.2 <2.8 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/flex-layout@5.0.0-beta.14 requires a peer of @angular/cdk@^5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/flex-layout@5.0.0-beta.14 requires a peer of @angular/core@^5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/flex-layout@5.0.0-beta.14 requires a peer of @angular/common@^5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/flex-layout@5.0.0-beta.14 requires a peer of rxjs@^5.5.0 but none is installed. You must install peer dependencies yourself.
npm WARN @ngtools/webpack@6.0.3 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/http-loader@3.0.1 requires a peer of @ngx-translate/core@>=10.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN tsickle@0.27.5 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
答案 2 :(得分:4)
在进行如下所示的强制更新后,该问题已为我解决:-
ng更新--all --force
它基本上避免/忽略所有依赖项检查,并在适用的情况下更新所有软件包。
答案 3 :(得分:1)
我能够使用以下方法来绕过有关不兼容对等方的消息:
ng更新--all
它更新了所有需要更新的软件包。
答案 4 :(得分:0)
不要强制更新,以后会出现意外结果。请改用以下npm安装,然后重试。
npm install -g @angular-devkit/schematics-cli
答案 5 :(得分:0)
您可以尝试:
npm i --save-dev @angular/cli@version @angular/core@version
然后您可以运行ng update --all
这对我有用。
我在使用Incompatible peer dependencies found. See above.
更新@angular/cli
和@angular/core
时得到了ng update --all
。
答案 6 :(得分:0)
此命令在我的情况下有效:
npm install --force @angular/cli@version @angular/core@version
这里的版本可能是您要升级的6,7,8,9,10
答案 7 :(得分:0)
运行 --force 不是正确的选择。因为它在抱怨 rxjs 和 typescript,所以你需要先升级它。完成后,您可以运行 angular update 命令