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

react-native-reanimated配置Babel出现Unknown option .pre报错如何解决

问题解决方法

错误原因为你将react-native-reanimated的Babel插件错误配置到了presets数组中,该插件属于plugins配置项,不属于预设类配置,位置错误导致Babel解析配置时抛出未知参数错误。

第一步:修正babel.config.js配置

将配置调整为如下格式,注意如果有其他Babel插件,需要保证react-native-reanimated的插件放在plugins数组的最后一项:

module.exports = {
  presets: [
    'module:metro-react-native-babel-preset'
  ],
  plugins: [
    'react-native-reanimated/plugin'
  ]
};

第二步:重置缓存并重新编译

  • 停止当前运行的metro服务
  • 执行npx react-native start --reset-cache重启metro并清空缓存
  • 新开终端窗口执行编译命令:
    • Android平台:先进入android目录执行./gradlew clean(Windows系统执行gradlew.bat clean)清空构建缓存,再执行npx react-native run-android重新安装应用
    • iOS平台:先进入ios目录执行pod install更新依赖,再执行npx react-native run-ios重新安装应用

关于是否需要提交Issue

该问题属于配置书写错误,不是react-native-reanimated的库bug,不需要提交Issue到GitHub。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.09.24 11:15:10