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

React Native Android应用构建失败原因排查求助

解决npm ERESOLVE依赖冲突错误

错误详情:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: [冲突包名]@x.x.x
npm ERR! Found: react@18.2.0
npm ERR! node_modules/react
npm ERR! react@"^18.2.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.8.0 || ^17.0.0" from [冲突包名]@x.x.x
npm ERR! node_modules/[冲突包名]
npm ERR! [冲突包名]@"^x.x.x" 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.

解决方案:

  • 快速临时解决:使用--legacy-peer-deps参数跳过peer依赖校验,沿用npm v6的解析逻辑:

    npm install --legacy-peer-deps
    

    注:此方法仅能完成安装,后续可能出现运行时兼容性问题。

  • 彻底解决版本冲突:

    1. 降级React版本到兼容范围:如果冲突包暂不支持React 18,可将React降级到17.x版本:
      npm install react@17.0.2 react-dom@17.0.2
      
    2. 更新冲突包到兼容版本:查看冲突包的官方文档或npm页面,确认是否有支持React 18的新版本,执行更新:
      npm update [冲突包名]
      
  • 清理缓存重试:若缓存导致异常,清理后重新安装:

    npm cache clean --force
    rm -rf node_modules package-lock.json
    npm install
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.13 17:35:37