使用npm install出现依赖冲突问题,但yarn install可正常执行
npm依赖解析错误(ERESOLVE)
错误截图
输入图片描述
触发场景
在路径G:\React Native\IGram下执行 npm install 命令时,出现依赖冲突错误。
错误日志详情
PS G:\React Native\IGram> npm install npm错误!代码:ERESOLVE npm错误!解析依赖时:react-native-otp-textinput@1.1.5 npm错误!已找到:react-native@0.73.7 npm错误!node_modules/react-native npm错误! 根项目中的react-native@"^0.73.7" npm错误! react-native-flash-message@0.4.2的peer依赖react-native@"*" npm错误! node_modules/react-native-flash-message npm错误! 根项目中的react-native-flash-message@"^0.4.2" npm错误! 另有15个依赖(react-native-iphone-screen-helper等) npm错误! npm错误!无法解析依赖: npm错误!react-native-otp-textinput@1.1.5的peer依赖react-native@"^0.72.4" npm错误!node_modules/react-native-otp-textinput npm错误! 根项目中的react-native-otp-textinput@"^1.1.5" npm错误! npm错误!存在冲突的peer依赖:react-native@0.72.14 npm错误!node_modules/react-native npm错误! react-native-otp-textinput@1.1.5的peer依赖react-native@"^0.72.4" npm错误! node_modules/react-native-otp-textinput npm错误! 根项目中的react-native-otp-textinput@"^1.1.5" npm错误! npm错误!请修复上游依赖冲突,或使用--force、--legacy-peer-deps参数重新执行命令 npm错误!以接受不正确(可能存在问题)的依赖解析结果。 npm错误! npm错误!完整报告请查看:C:\Users\tejpr\AppData\Local\npm-cache\eresolve-report.txt npm错误!本次运行的完整日志可在以下路径找到: npm错误! C:\Users\tejpr\AppData\Local\npm-cache_logs\2024-05-06T06_05_02_340Z-debug-0.log
可行解决方式
- 临时绕过冲突,执行以下任一命令:
npm install --force:强制npm忽略依赖冲突完成安装npm install --legacy-peer-deps:采用旧版peer依赖解析逻辑,跳过冲突校验
- 彻底解决冲突:
- 检查
react-native-otp-textinput是否有适配react-native@0.73.x的版本,若有则升级该包:npm install react-native-otp-textinput@[最新兼容版本号] - 若该包暂无兼容版本,可降级react-native至0.72.x系列:
npm install react-native@^0.72.14
- 检查
内容的提问来源于stack exchange,提问作者Tejpreet Singh
相关产品推荐
相关产品推荐

