You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

安装mdb-react-ui-kit时出现ERESOLVE依赖树解析错误求助

解决npm安装mdb-react-ui-kit时的ERESOLVE依赖冲突问题

执行命令 npm i mdb-react-ui-kit 时出现如下错误:

PS C:\Users\asus\Desktop\web clone> npm i mdb-react-ui-kit
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: travel-react-app@0.1.0
npm ERR! Found: react@17.0.2
npm ERR! node_modules/react
npm ERR!   react@"^17.0.2" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^18.1.0" from mdb-react-ui-kit@6.2.0
npm ERR! node_modules/mdb-react-ui-kit
npm ERR!   mdb-react-ui-kit@"*" 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!
npm ERR! For a full report see:
npm ERR! C:\Users\asus\AppData\Local\npm-cache\_logs\2023-09-09T02_18_54_224Z-eresolve-report.txt

npm ERR! A complete log of this run can be found in: C:\Users\asus\AppData\Local\npm-cache\_logs\2023-09-09T02_18_54_224Z-debug-0.log

其他项目安装该包无问题,以下是几种可行的解决方法:

  • 升级React到兼容版本
    既然mdb-react-ui-kit@6.2.0要求React@^18.1.0,直接升级项目的React和ReactDOM:

    npm install react@^18.1.0 react-dom@^18.1.0
    

    升级后需要检查项目代码是否适配React18的新特性,比如自动批量更新、StrictMode的变化等,确保功能正常运行。

  • 使用旧版依赖解析逻辑安装
    若暂时无法升级React,可通过--legacy-peer-deps参数跳过peer依赖版本检查:

    npm install mdb-react-ui-kit --legacy-peer-deps
    

    此方法会忽略版本冲突,但可能存在组件兼容性风险,安装后需重点测试mdb组件的功能是否正常。

  • 安装适配React17的mdb-react-ui-kit版本
    查找支持React17的mdb-react-ui-kit版本(如5.x系列),指定版本安装:

    npm install mdb-react-ui-kit@5.x
    

    可通过npm官方仓库确认具体版本的peer依赖要求,选择最适配项目的版本。

内容的提问来源于stack exchange,提问作者Krizzyp19

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.11 04:04:55