记录一下Found: react@18.0.0npm ERR! node_modules/reactnpm ERR! react@“^18.0.0“ from the root project

当执行npminstall时遇到ERESOLVE无法解析依赖关系树的错误,这是由于npm版本升级导致的新策略,不再自动忽略依赖冲突。解决方法包括使用--force强制安装或--legacy-peer-deps参数来忽视依赖冲突并继续安装。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 问题描述:npm install 时报错

原因:

ERESOLVE unable to resolve dependency tree ---ERESOLVE 无法解析依赖关系树

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

修复上游依赖冲突,或重试
此命令带有 --force,或 --legacy-peer-deps
接受不正确(且可能损坏)的依赖项解析

根据报错信息可以得知是因为依赖冲突导致不能下载依赖包

查阅资料得知由于npm版本升级的原因造成的

npm v7之前的版本遇到依赖冲突会忽视依赖冲突,继续进行安装
npm v7版本开始不会自动进行忽略,需要用户手动输入命令

解决方法1 npm install  --force 无视冲突,强制获取远端npm库资源 (覆盖之前)
解决方法2 npm install  --legacy-peer-deps 忽视依赖冲突,继续安装(不覆盖之前)

 

success !

 

npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve dependency tree npm ERR! npm ERR! While resolving: myApp@1.0.0 npm ERR! Found: @types/react@18.3.20 npm ERR! node_modules/@types/react npm ERR! dev @types/react@"^18.0.0" from the root project npm ERR! peerOptional @types/react@"^18" from @tarojs/taro@4.0.9 npm ERR! node_modules/@tarojs/taro npm ERR! @tarojs/taro@"4.0.9" from the root project npm ERR! peer @tarojs/taro@">=3" from taro-ui@3.3.0 npm ERR! node_modules/taro-ui npm ERR! taro-ui@"^3.2.1" from the root project npm ERR! 2 more (@tarojs/components, @tarojs/taro-rn) npm ERR! npm ERR! Could not resolve dependency: npm ERR! peerOptional @types/react@"^19.0.0" from react-native@0.78.1 npm ERR! node_modules/react-native npm ERR! peer react-native@">=0.62.0" from taro-ui@3.3.0 npm ERR! node_modules/taro-ui npm ERR! taro-ui@"^3.2.1" from the root project npm ERR! peer react-native@"*" from @bam.tech/react-native-image-resizer@3.0.11 npm ERR! node_modules/@bam.tech/react-native-image-resizer npm ERR! peer @bam.tech/react-native-image-resizer@"^3.0.10" from @tarojs/taro-rn@4.0.9 npm ERR! node_modules/@tarojs/taro-rn npm ERR! peer @tarojs/taro-rn@">=3" from taro-ui@3.3.0 npm ERR! node_modules/taro-ui 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:\Program Files\nodejs\node_cache\_logs\2025-03-26T05_07_21_020Z-eresolve-report.txt npm ERR! A complete log of this run can be found in: C:\Program Files\nodejs\node_cache\_logs\2025-03-26T05_07_21_020Z-debug-0.log
最新发布
03-27
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值