2

I am working on a React Native Expo project and trying to use Babel to transpile my code. However, when I run the expo start command, I get the following error message:

You appear to be using a native ECMAScript module configuration file, which is only supported when running Babel asynchronously.

I am running Node.js version 16.19.1 and React Native Expo.

What is causing this error, and how can I fix it?

I have tried updating my babel.config.js file to include the "env" and "react-native" presets, but the error persists. Here is my current babel.config.js file:

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

1 Answers1

0

Can you try setting the target node version to current? It is also suggested to rename the babel.config.js to babel.config.cjs or babel.config.json. Here is the reference link

module.exports = { 
  presets: [
    'module:metro-react-native-babel-preset',
    {
      targets: {
        node: 'current'
      }
    },
    '@babel/preset-env', 
    {
      targets: {
        node: 'current'
      }
    },
    '@babel/preset-react-native',
    {
      targets: {
        node: 'current'
      }
    }
  ]
};