繁体   English   中英

在 angular 13 上安装 ngx-toastr 时,ERESOLVE 无法解析依赖关系树

[英]ERESOLVE unable to resolve dependency tree while installing ngx-toastr on angular 13

尝试在我的 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:\Users\xyz\AppData\Local\npm-cache\eresolve-report.txt for a full report.
    
    npm ERR! A complete log of this run can be found in:
    npm ERR!     C:\Users\xyz\AppData\Local\npm-cache\_logs\2022-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 安装 ngx-toastr --force

  5. 更新 angular.json 文件(“样式”数组)“./node_modules/font-awesome/css/font-awesome.css”“./node_modules/ngx-toastr/toastr.css”“

如果您收到有关“font-awesome”的错误 Run -> npm install --save font-awesome --force

第二种方式(这也有效):

  1. 更新 npm
  2. 按照以下说明更新 Angular 应用程序: https://update.angular.io/
  3. 运行:npm install ngx-toastr
  4. 运行:npm install --save font-awesome
  5. 更新 angular.json 文件(“样式”数组)“./node_modules/font-awesome/css/font-awesome.css”“./node_modules/ngx-toastr/toastr.css”“

希望这会有所帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM