ERROR Error: Reanimated 2 failed to create a worklet

created at 12-11-2021 views: 2

error

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

Solution

Modify the configuration file babel.config.js and add

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

Here, if you run the project, you will find that the error is still reported. The cache is at fault.

Clear cache

  • yarn
yarn start --reset-cache
  • npx
npx react-native start --reset-cache

Here is restarting and running the project, there will be no such mistake.

Puzzled

In fact, I also used react-native-reanimated in my old project, and I did not add it to the configuration file babel.config.js

plugins: [‘react-native-reanimated/plugin’]

But the project can run normally.

This must be added to the new project to run, I don't understand it very much.

I guess it's because I used the ant design component in the old project, but not in the new project. At the moment I can only find the difference.

Please log in to leave a comment.