namespace transformed `@babel/plugin-proposal-export-namespace-from

Total
0
Shares

When running a react native application using cli, we sometimes get React Native error: Export namespace should be first transformed by `@babel/plugin-proposal-export-namespace-from. This happens while using some plugins like react-native-reanimated.

Why this error occurs?

The main reason for this error is that you forgot to register the plugin in babel config file. As directed by plugin installation instructions, it is need to add plugin to babel.config.js like this –

module.exports = {
      ...
      plugins: [
          ...
          'react-native-reanimated/plugin',
      ],
  };

Note: The reanimated plugin should be added at last in plugins array.

Solution

1. Install plugin using below command –

yarn add react-native-reanimated

2. Add reanimated to babel.config.js –

module.exports = {
      ...
      plugins: [
          ...
          'react-native-reanimated/plugin',
      ],
  };

3. If you got Reanimated 2 failed to create a worklet error, then clear the cache –

yarn start --reset-cache
// npm start -- --reset-cache
// expo start -c

4. Run the app

These steps will solve your error of React Native error: Export namespace should be first transformed by `@babel/plugin-proposal-export-namespace-from.