0

我做了什么导致错误: 我有一个新安装的 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 与 Node\healthapp\node_modules@babel\core\lib\config\files\plugins.js
  • D:\Work\React Native\React Native 与 Node\healthapp\node_modules@babel\core\lib\config\files\index.js
  • D:\Work\React Native\React Native 与 Node\healthapp\node_modules@babel\core\lib\index.js
  • D:\Work\React Native\React Native 与 Node\healthapp\node_modules\metro-transform-worker\src\index.js
  • D:\Work\React Native\React Native 与 Node\healthapp\node_modules\metro\src\DeltaBundler\Worker.js
  • D:\Work\React Native\React Native 与 Node\healthapp\node_modules\metro\node_modules\jest-worker\build\workers\processChild.js
4

2 回答 2

0

我希望你已经解决了这个问题。但是以防万一或其他人在我的情况下需要它,这是由于我从说明中复制这部分代码时留下的省略号(...):

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

https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/installation/

于 2022-02-09T03:24:33.207 回答
0

这是一个与 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

于 2021-11-07T04:23:26.210 回答