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

React Native+TypeScript项目npm安装测试库遇ERESOLVE依赖树错误

React Native项目依赖版本冲突问题

在React Native + TypeScript项目中执行以下命令安装测试库时,出现npm ERESOLVE错误,无法解析依赖树:

npm install @testing-library/react-native @testing-library/jest-native --save-dev

错误核心是项目中当前的react@18.2.0版本,与react-test-renderer@18.3.1要求的peer依赖react@^18.3.1存在版本冲突。

尝试使用--legacy-peer-deps参数临时绕过该问题后,在安装ESLint时再次触发了同类ERESOLVE解析错误。


相关命令输出

执行npm ls react-dom的输出:

productoverviewapp@1.0.0 /Users/App
└── (empty)

执行npm ls react的输出:

productoverviewapp@1.0.0 /Users/****/App
├─┬ @testing-library/jest-native@5.4.3
│ └── react@18.2.0 deduped
├─┬ @testing-library/react-native@12.7.2
│ └── react@18.2.0 deduped
├─┬ react-native-fast-image@8.6.3
│ └── react@18.2.0 deduped
├─┬ react-native@0.74.5
│ ├─┬ @react-native/virtualized-lists@0.74.87
│ │ └── react@18.2.0 deduped
│ ├─┬ react-shallow-renderer@16.15.0
│ │ └── react@18.2.0 deduped
│ └── react@18.2.0 deduped
└── react@18.2.0

安装ESLint时的错误信息:

npm error code ERESOLVE
npm error ERESOLVE could not resolve
npm error
npm error While resolving: @testing-library/jest-native@5.4.3
npm error Found: react@18.2.0

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.18 04:56:09