您当前的位置: 首页 > 

ITKEY_

暂无认证

  • 0浏览

    0关注

    732博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

ERROR Error: Reanimated 2 failed to create a worklet

ITKEY_ 发布时间:2021-12-10 11:11:56 ,浏览量:0

报错
To reload the app press "r"
To open developer menu press "d"

 BUNDLE  ./index.js 

 ERROR  Error: Reanimated 2 failed to create a worklet, maybe you forgot to add Reanimated's babel plugin?, js engine: hermes
 ERROR  Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication). A frequent cause of the error is that the application entry file path is incorrect.
      This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native., js engine: hermes
 ERROR  Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication). A frequent cause of the error is that the application entry file path is incorrect.
      This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native., js engine: hermes
解决办法

修改配置文件babel.config.js并增加plugins: ['react-native-reanimated/plugin'], module.exports = { presets: [‘module:metro-react-native-babel-preset’], plugins: [‘react-native-reanimated/plugin’], };

这里你如果运行项目会发现报错依旧。是缓存在作怪。

清缓存
  • yarn
yarn start --reset-cache
  • npx
npx react-native start --reset-cache

这里在重启运行项目,就不会有这个错了。

百思不得解

其实在我老的项目中也用到了react-native-reanimated,而且我并没有在配置文件babel.config.js中增加

plugins: [‘react-native-reanimated/plugin’], 但是项目是可以正常运行的。

新项目中就必须加上这个才能运行,我非常不理解。

我猜测会不会是因为我在老项目中使用了ant design这个组件了,而新项目中没有使用这个组件。目前我只能找出这个区别。

参考

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

https://stackoverflow.com/questions/67130651/reanimated-2-failed-to-create-a-worklet-maybe-you-forgot-to-add-reanimateds-ba

关注
打赏
1665243900
查看更多评论
立即登录/注册

微信扫码登录

0.0398s