Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

You appear to be using a native ECMAScript module configuration file, Babel asynchronously React Native

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'], };

like image 503
Rytis Jokubas Avatar asked Apr 11 '26 08:04

Rytis Jokubas


1 Answers

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'
      }
    }
  ]
};
like image 170
Bhishak Sanyal Avatar answered Apr 14 '26 06:04

Bhishak Sanyal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!