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

React依赖冲突:安装项目依赖时遇ERESOLVE错误求助

问题描述

Node.js版本:v20.3.1
执行npm i --save时触发ERESOLVE依赖冲突错误,原因是tailwind-rn-gust@1.0.1要求peer依赖react@"^16.8.0",但当前项目依赖的是react@18.2.0。已尝试npm install(注:原输入node install为笔误)和npm i --force,均未解决问题。

错误日志:

L@DESKTOP- MINGW64 ~/nextjs-whatsapp-clone-starter (main)
$ npm i --save
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: tailwind-rn-gust@1.0.1
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" from tailwind-rn-gust@1.0.1
npm ERR! node_modules/tailwind-rn-gust
npm ERR!   tailwind-rn-gust@"^1.0.1" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: react@16.14.0
npm ERR! node_modules/react
npm ERR!   peer react@"^16.8.0" from tailwind-rn-gust@1.0.1
npm ERR!   node_modules/tailwind-rn-gust
npm ERR!     tailwind-rn-gust@"^1.0.1" 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.
npm ERR!
npm ERR! See D:\Users\L\AppData\Local\npm-cache\eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     D:\Users\L\AppData\Local\npm-cache\_logs\2023-07-04T01_09_38_305Z-debug-0.log
解决方案

1. 使用--legacy-peer-deps参数安装

npm v7及以上版本默认严格校验peer依赖,--legacy-peer-deps会切换回npm v6的处理逻辑,跳过严格的peer依赖校验,比--force更安全(不会强制覆盖其他依赖):

npm i --save --legacy-peer-deps

2. 检查并升级tailwind-rn-gust版本

先查看该包是否有更新版本支持React 18:

npm show tailwind-rn-gust versions

如果存在更高兼容版本,修改package.json中tailwind-rn-gust的版本号为最新版,再执行npm install。

3. 替换为维护活跃的替代包

如果tailwind-rn-gust长期未更新(无React 18兼容版),可以替换为其他支持React 18的React Native Tailwind CSS工具,比如tailwind-rn官方包。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.17 02:33:12