Skip to content

依赖冲突 #1840

@JiQingzhe2004

Description

@JiQingzhe2004

问题描述
在 Taro 4.1.1 + React 18 环境下安装 taro-ui@3.3.0 时,出现严重的版本依赖冲突。taro-ui 3.x 强制要求 React 19 类型定义,但 Taro 4.1.1 核心库依赖 React 18,导致项目无法正常构建。

复现步骤

  1. 使用 Taro CLI 初始化项目:
    taro init NongHi --framework react --typescript
  2. 安装基础依赖:
    npm install
  3. 尝试安装 taro-ui:
    npm install taro-ui@3.3.0
  4. 出现依赖解析错误(完整错误见下文)

期望行为
taro-ui 3.x 应该提供兼容 React 18 的版本,或 Taro 官方文档应明确标注版本兼容矩阵。

报错信息

npm error ERESOLVE unable to resolve dependency tree
npm error While resolving: NongHi@1.0.0
npm error Found: @types/react@18.3.21
npm error Could not resolve dependency:
npm error peerOptional @types/react@"^19.0.0" from react-native@0.79.2
npm error Conflict caused by:
npm error taro-ui@3.3.0 → react-native@0.79.2 → @types/react@^19.0.0
npm error Fix with:
npm error npm install --legacy-peer-deps

系统信息

  • Taro 版本:v4.1.1
  • Taro UI 版本:v3.3.0
  • Node.js 版本:v18.20.2
  • 平台:weapp
  • 包管理工具:npm 8.19.4

补充信息

  1. 根本原因分析:
    • taro-ui 3.x 的 react-native 依赖未做好向后兼容
    • Taro 官方未在文档中明确版本要求

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions