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
相关产品推荐
相关产品推荐

