[英]Compilation error with react-native-reanimated and babel
我想将react-native-reanimated
添加到我的项目中,我按照安装指南进行操作,在为 Babel 添加插件时,我在启动应用程序时收到错误消息:
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.
我使用的是Android device
,因此我启用了 Hermes 并在 MainApplication 中创建了该方法。 我怎么解决这个问题? 我是否必须在 GitHub 上发布问题?
babel.config.js
module.exports = {
presets: [
'module:metro-react-native-babel-preset',
'react-native-reanimated/plugin',
],
};
依赖项
"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",
尝试的解决方案:
react-native start --reset-cache
。我有同样的问题,然后意识到它应该在plugins
中,而不是presets
中。 只需将'react-native-reanimated/plugin'
移动到插件中:
module.exports = {
presets: [
'module:metro-react-native-babel-preset',
- 'react-native-reanimated/plugin',
],
+ plugins: [
+ 'react-native-reanimated/plugin'
+ ],
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.