erresolve在angular 13上安装ngx-toastr时无法解析依赖树



尝试在我的angular 13上安装ngx-toastr时出现以下错误

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: p4-padmin@0.0.0
npm ERR! Found: @angular/common@13.0.3
npm ERR! node_modules/@angular/common
npm ERR!   @angular/common@"~13.0.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/common@">=14.0.0-0" from ngx-toastr@15.0.0
npm ERR! node_modules/ngx-toastr
npm ERR!   ngx-toastr@"*" 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 C:UsersxyzAppDataLocalnpm-cacheeresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:UsersxyzAppDataLocalnpm-cache_logs2022-06-27T09_19_20_284Z-debug.log

这对我有用:

  1. 删除node_modules, package-lock.json

  2. 更新npm ->Sudo NPM install -g NPM (mac上)

  3. 运行→NPM安装在angular项目目录

  4. 运行npm install ngx-toastr——force

  5. 更新角。Json文件("数组)"。/node_modules/font-awesome/css/font-awesome.css"。/node_modules/ngx-toastr/toastr.css">

如果你报错"font-awesome"默认运行环境;NPM install——save font-awesome——force

第二种方法(同样有效):

  1. 更新npm
  2. 按照下列指令更新Angular应用:https://update.angular.io/
  3. 运行:npm install ngx-toastr运行:npm install——save font-awesome
  4. 更新角。Json文件("数组)"。/node_modules/font-awesome/css/font-awesome.css"。/node_modules/ngx-toastr/toastr.css">

希望对你有帮助。

最新更新