【问题标题】:error: index.js: Cannot find module 'babel-plugin-r' React Native错误:index.js:找不到模块'babel-plugin-r' React Native
【发布时间】:2021-10-28 12:35:00
【问题描述】:

我做了什么导致错误: 我有一个新安装的 Bare React Native Project 。我想使用抽屉导航,不得不安装 React Native Reanimated 2.3.0-alpha.2 。

我已经尝试解决的错误

错误

捆绑包./index.js

错误:index.js:找不到模块“babel-plugin-r” 需要堆栈:

  • D:\Work\React Native\React Native with Node\healthapp\node_modules@babel\core\lib\config\files\plugins.js
  • D:\Work\React Native\React Native with Node\healthapp\node_modules@babel\core\lib\config\files\index.js
  • D:\Work\React Native\React Native with Node\healthapp\node_modules@babel\core\lib\index.js
  • D:\Work\React Native\React Native with Node\healthapp\node_modules\metro-transform-worker\src\index.js
  • D:\Work\React Native\React Native with Node\healthapp\node_modules\metro\src\DeltaBundler\Worker.js
  • D:\Work\React Native\React Native with Node\healthapp\node_modules\metro\node_modules\jest-worker\build\workers\processChild.js

【问题讨论】:

  • 你弄明白了吗?我在 beta.2 中遇到了类似的问题,但是使用了模块 'babel-plugin-typescript'

标签: android react-native react-navigation navigation-drawer react-native-reanimated-v2


【解决方案1】:

这是一个与 babel 相关的问题。

确保安装

"@babel/core": "^7.12.9",

"@babel/runtime": "^7.16.0",

"@babel/plugin-transform-runtime": "^7.16.0",

或任何最新版本。

在您的 babel.config.js 文件中,添加以下内容:

plugins: [
            [
                '@babel/plugin-transform-runtime',
                {
                    absoluteRuntime: false,
                    corejs: false,
                    helpers: true,
                    regenerator: true,
                    version: '7.0.0-beta.0',
                },
            ],
            'react-native-reanimated/plugin',
        ],

如果您有其他插件,请确保重新激活的插件是最后一个。 对于其他措施,删除节点模块并清除缓存。 更多在这里: https://babeljs.io/docs/en/babel-plugin-transform-runtime

【讨论】:

    猜你喜欢
    • 2020-01-13
    • 2019-09-04
    • 2022-09-28
    • 2019-03-03
    • 1970-01-01
    • 1970-01-01
    • 2022-08-15
    • 2016-10-27
    • 1970-01-01
    相关资源
    最近更新 更多