我在用
- 角 14.2.6
- 節點 16.17.0
- Npm 8.15.0
這是的輸出ng version
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 14.2.6
Node: 16.17.0
Package Manager: npm 8.15.0
OS: win32 x64
Angular: 14.2.6
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Package Version
------------------------------------------------------------
@angular-devkit/architect 0.1402.6
@angular-devkit/build-angular 14.2.6
@angular-devkit/core 14.2.6
@angular-devkit/schematics 14.2.6
@angular/cdk 14.2.5
@angular/flex-layout 14.0.0-beta.41
@angular/material 14.2.5
@angular/material-moment-adapter 14.2.5
@schematics/angular 14.2.6
rxjs 7.5.7
typescript 4.8.4
當我npm instll更新我的包時,我收到以下錯誤:
$ npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: angular-user-idle@3.0.0
npm ERR! Found: @angular/common@14.2.6
npm ERR! node_modules/@angular/common
npm ERR! @angular/common@"~14.2.6" from the root project
npm ERR! peer @angular/common@"^14.0.0 || ^15.0.0" from @angular/cdk@14.2.5
npm ERR! node_modules/@angular/cdk
npm ERR! @angular/cdk@"^14.2.5" from the root project
npm ERR! peer @angular/cdk@"^14.0.0" from @angular/flex-layout@14.0.0-beta.41
npm ERR! node_modules/@angular/flex-layout
npm ERR! @angular/flex-layout@"^14.0.0-beta.41" from the root project
npm ERR! 1 more (@angular/material)
npm ERR! 6 more (@angular/flex-layout, @angular/forms, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/common@"^13.3.0" from angular-user-idle@3.0.0
npm ERR! node_modules/angular-user-idle
npm ERR! angular-user-idle@"^3.0.0" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: @angular/common@13.3.11
npm ERR! node_modules/@angular/common
npm ERR! peer @angular/common@"^13.3.0" from angular-user-idle@3.0.0
npm ERR! node_modules/angular-user-idle
npm ERR! angular-user-idle@"^3.0.0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
我知道我可以嘗試使用npm install --force或npm install --legacy-peer-deps按照上面錯誤訊息的最后兩行中的建議,但是,該建議看起來并不令人鼓舞,因為它說“ ......接受和不正確(并且可能被破壞)的依賴關系決議。 ”
我不確定如何進行?我也不認為降級 npm/node 是一個好建議。
更新
遵循@skinks 的建議并將“覆寫”部分添加到 package.json 中,例如:
{
...
,
"overrides": {
"angular-user-idle": {
"@angular/common": "$@angular/common",
"@angular/core": "$@angular/core"
}
},
...
導致npm audit fix產生以下內容:
# npm audit report
angular *
Severity: moderate
angular vulnerable to regular expression denial of service (ReDoS) - https://github.com/advisories/GHSA-m2h2-264f-f486
Angular (deprecated package) Cross-site Scripting - https://github.com/advisories/GHSA-prc3-vjfx-vhm9
fix available via `npm audit fix`
node_modules/angular
uj5u.com熱心網友回復:
可以覆寫angular-user-idle包的對等依賴項:
包.json
{
...
"overrides": {
"angular-user-idle": {
"@angular/common": "$@angular/common", // means: use the version from the project instead of the one that the package actually depends on
"@angular/core": "$@angular/core"
}
}
}
這種方法比--force標志更可取,因為您可以很好地控制依賴關系。
uj5u.com熱心網友回復:
angular-user-idle有 Angular 13 作為依賴項,除了嘗試--force安裝以查看該庫是否適用于 Angular 14 之外,別無他法。
由于 Angular 14 并沒有帶來太多重大變化,所以應該沒問題。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/518139.html
上一篇:總銷售額的每日銷售額
