无法在 Angular 12.1.4 上安装 PrimeNg。 npm 错误

Unable to install PrimeNg on Angular 12.1.4. npm Error

我正在尝试将 PrimeNg 添加到我的项目中,但是我收到了这个奇怪的错误,我不确定如何修复它。谁能帮我吗?我机器上安装的 angular 当前版本是 12.1.4.

205-185-99-116:learngaroo sulavdahal$ npm install primeng --save
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: learngaroo@0.0.0
npm ERR! Found: @angular/common@12.2.0
npm ERR! node_modules/@angular/common
npm ERR!   @angular/common@"^12.1.0" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/common@"^7.0.0 || ^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0" from primeng@11.4.5
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! See /Users/sulavdahal/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/sulavdahal/.npm/_logs/2021-08-10T21_33_04_601Z-debug.log

它抱怨同伴依赖。这应该有效:

npm install primeng --save --force

您可能希望避免给出 --force 标志。此问题是由于版本不匹配。如果您使用 --force 安装,它会导致应用程序在许多情况下表现异常。 你的 Angular 版本是 12,primeng 版本(默认,当你给 npm i primeng --save 时)是 11.4。您可能想尝试安装 12.0.1 版本。