我正在使用
- Angular 14.2.6
- 节点16.17.0
- 每分钟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的建议,并将“overrides”部分添加到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
更新2
根据@skinks的建议,我在我的package-lock.json中发现了以下对“angular”(angularjs)的引用:
2条答案
按热度按时间i86rm4rw1#
可以覆盖
angular-user-idle
包的对等依赖关系:包. json
这种方法比
--force
标志更可取,因为您可以对依赖项进行精细控制。fslejnso2#
angular-user-idle
有angular 13作为依赖项,除了尝试安装--force
以查看库是否能与Angular 14一起正常工作之外,没有什么别的事情要做。由于Angular 14没有带来太多的突破性变化,它应该是好的。