尝试安装
primeng
时,我遇到以下错误消息:
npm i primeng
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: @angular/[email protected]
npm ERR! node_modules/@angular/common
npm ERR! @angular/common@"~16.2.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/common@"^17.0.0" from [email protected]
npm ERR! node_modules/primeng
npm ERR! primeng@"*" 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 ERR!
npm ERR!
出现此错误的原因是
primeng
需要Angular版本17,而我的项目当前使用的是Angular版本16。我的package.json
文件中列出的相关依赖项包括:
"@angular/animations": "~16.2.0",
"@angular/common": "~16.2.0",
"@angular/compiler": "~16.2.0",
"@angular/core": "~16.2.0",
"@angular/forms": "~16.2.0",
"@angular/platform-browser": "~16.2.0",
"@angular/platform-browser-dynamic": "~16.2.0",
"@angular/router": "~16.2.0",
"@nx/angular": "16.10.0"
为了确定哪个版本的
primeng
与我当前的 Angular 版本兼容,而不需要对不同版本进行反复试验,我需要一种通过 npm 确定兼容性的方法。
npm 有没有办法提供有关哪个版本的
primeng
与我的 package.json
文件中指定的 Angular 版本兼容的信息?
尝试使用以下命令,它应该可以工作。
npm i primeng --legacy-peer-deps