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

无法解析react-native-reanimated/src/core/AnimatedEvent模块问题咨询

React Native AnimatedEvent 模块解析报错修复方案

报错信息:Unable to resolve module react-native-reanimated/src/core/AnimatedEvent

报错根本原因

该问题由react-native-reanimated版本不兼容导致:react-native-reanimated v2.x 及更高版本调整了内部模块路径,AnimatedEvent不再从src/core/路径导出;若项目中其他依赖(如手势库、导航抽屉组件)要求的reanimated版本和你安装的版本不匹配,或者依赖安装过程中版本号自动升级超出兼容范围,就会触发该报错。

修复步骤

  • 先对齐依赖版本:查看项目中依赖react-native-reanimated的第三方库(比如react-native-gesture-handler、@react-navigation/drawer)的package.json说明,安装对应要求的reanimated大版本,比如第三方库要求>=2.14.0 <3.0.0时,不要安装3.x系列版本
  • 完全清理旧依赖与缓存:
    # 清理现有依赖和版本锁定文件
    rm -rf node_modules package-lock.json yarn.lock
    # 清理npm全局缓存
    npm cache clean --force
    # 重装依赖
    npm install
    # iOS端额外执行Pod清理重装
    cd ios && rm -rf Pods Podfile.lock && pod install && cd ..
    
  • 重置Metro缓存启动项目:
    npx react-native start --reset-cache
    
  • 若仍报错,检查项目代码中是否存在手写的绝对路径导入react-native-reanimated/src/core/AnimatedEvent,改为官方标准导入写法:
    import { AnimatedEvent } from 'react-native-reanimated'
    

是否需要从头搭建项目

不需要,该问题属于常见的React Native依赖兼容性问题,按照上述步骤操作即可解决,无需重建项目。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.09.26 00:36:04