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

集成react-native-firebase时遇this.getOptions is not a function错误求助

解决babel-loader构建错误:TypeError: this.getOptions is not a function

问题根源

你的依赖包存在版本冲突:babel-loader@9.1.2 是为 Babel 7 和 Webpack 5 设计的,但你同时安装了 Babel 6 版本的 babel-core 和 babel,且未明确安装适配的 Webpack 版本,导致构建时调用了不兼容的 API。另外 React Native 0.71 本身依赖 Babel 7,旧版 Babel 包会和 RN 内置配置冲突。

解决步骤

  1. 卸载旧版 Babel 包
# 使用 yarn
yarn remove babel babel-core

# 使用 npm
npm uninstall babel babel-core
  1. 安装 Babel 7 核心依赖
# 使用 yarn
yarn add @babel/core --dev

# 使用 npm
npm install @babel/core --save-dev
  1. 确保 Webpack 版本适配
    babel-loader@9.x 需要 Webpack 5,安装对应版本:
# 使用 yarn
yarn add webpack --dev

# 使用 npm
npm install webpack --save-dev
  1. 清理缓存并重新构建
# 使用 yarn
yarn cache clean
rm -rf node_modules yarn.lock
yarn install
yarn start --reset-cache

# 使用 npm
npm cache clean --force
rm -rf node_modules package-lock.json
npm install
npm start --reset-cache

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.04 12:55:20