我正在尝试将 PrimeNg 添加到我的项目中,但是,我收到这个奇怪的错误,我不知道如何修复它。谁能帮我吗?我的机器中当前安装的 Angular 版本是 12.1.4.
205-185-99-116:$ npm install primeng --save
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! Found: @angular/[email protected]
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 [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 install primeng --save --force
您可能想避免给出 --force 标志。此问题是由于版本不匹配造成的。如果使用 --force 安装,在许多情况下会导致应用程序行为异常。 你的 Angular 版本是 12,primeng 版本(默认,当你输入 npm i primeng --save 时)是 11.4。您可能想尝试安装 12.0.1 版本。