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

安装@react-three/drei与react-three/fiber@alpha时的依赖冲突及React降级问题

解决@react-three/drei与react-three/fiber@alpha的依赖冲突问题

核心问题原因

你遇到的冲突是因为@react-three/drei@9.121.3仅支持@react-three/fiber@^8.x版本,但你安装了fiber@9.0.0-alpha.8(v9 alpha版本),两者peer依赖不兼容。之前降级React到18无效是因为没匹配对应版本的fiber和drei,--legacy-peer-deps失效则是因为alpha版本的peer依赖规则更严格。

解决方案1:安装匹配的alpha版本(推荐,适配React 19)

既然你要使用fiber的alpha版本,必须搭配同阶段的drei alpha版本,具体步骤:

  1. 卸载现有冲突包:
npm uninstall @react-three/fiber @react-three/drei
  1. 同步安装两者的alpha版本:
npm install @react-three/fiber@alpha @react-three/drei@alpha

此时两者的版本都会是v9 alpha系列,peer依赖完全匹配,无需降级React。

解决方案2:回退到稳定版(适配React 18)

如果不需要fiber的alpha特性,可回退到v8稳定版,同时安装对应兼容的drei版本:

  1. 卸载现有包:
npm uninstall @react-three/fiber @react-three/drei react react-dom
  1. 安装React 18及对应版本的依赖:
npm install react@^18.2.0 react-dom@^18.2.0 @react-three/fiber@^8.15.0 @react-three/drei@^9.105.0

验证安装结果

执行以下命令确认依赖版本匹配:

npm ls @react-three/fiber @react-three/drei

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.14 19:35:59