最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Compilation error with react-native-reanimated and babel - Stack Overflow

programmeradmin4浏览0评论

I would like to add react-native-reanimated to my project, I followed the installation guide and at the time of adding the plugin for Babel I receive an error from it when launching the application :

error: index.js: [BABEL] W:\folders\project\index.js: Unknown option: .pre. Check out  for more information about options.

I am using an Android device, and therefore I have enabled Hermes and created the method in MainApplication. How can I solve this problem? Do I have to publish an issue on GitHub?

babel.config.js

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

Dependencies

"react": "17.0.1",
"react-native": "0.64.1",
"react-native-gesture-handler": "^1.10.3",
"react-native-reanimated": "2.3.0-beta.1",
"metro-react-native-babel-preset": "^0.64.0",

Solution tried:

  • Run react-native start --reset-cache.
  • Delete node_modules and reinstall.
  • Changing the library version.

I would like to add react-native-reanimated to my project, I followed the installation guide and at the time of adding the plugin for Babel I receive an error from it when launching the application :

error: index.js: [BABEL] W:\folders\project\index.js: Unknown option: .pre. Check out https://babeljs.io/docs/en/babel-core/#options for more information about options.

I am using an Android device, and therefore I have enabled Hermes and created the method in MainApplication. How can I solve this problem? Do I have to publish an issue on GitHub?

babel.config.js

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

Dependencies

"react": "17.0.1",
"react-native": "0.64.1",
"react-native-gesture-handler": "^1.10.3",
"react-native-reanimated": "2.3.0-beta.1",
"metro-react-native-babel-preset": "^0.64.0",

Solution tried:

  • Run react-native start --reset-cache.
  • Delete node_modules and reinstall.
  • Changing the library version.
Share Improve this question asked Dec 3, 2021 at 3:16 ablauseablause 881 silver badge6 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 24

I had the same issue and then realized that it should be in plugins, not presets. Simply move 'react-native-reanimated/plugin' into plugins:

module.exports = {
  presets: [
    'module:metro-react-native-babel-preset',
-   'react-native-reanimated/plugin',
  ],
+ plugins: [
+   'react-native-reanimated/plugin'
+ ],
}
发布评论

评论列表(0)

  1. 暂无评论