Changing babel.config.
This has got to do with Babel settings. The use of .mjs, cjs, or .js extension for the babel.config.extension. In my case where I was running LTE Node 12.6.2, I needed this configuration at the root of my directory babel.config.cjs. cjs is what is applicable for Node.js when using "type"="module". See more about it here on babel docs.
module.exports = {
presets: [
[
'@babel/preset-env',
{
targets: {
node: 'current'
}
}
]
]
};
And jest.config.cjs at the root too. --re-write this and HTML format, in a div without HTML and body element and add class="questionanswerbox" in div element.
In addition to the "cjs" solution, I was able to resolve this issue by converting babel.config.js to babel.config.json:
{
"presets": [
[
"@babel/preset-env",
{
"targets": {
"node": "current"
}
}
],
"@babel/preset-typescript"
]
}
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.
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'
}
}
]
};
I encountered a similar problem, and after reading the Babel site, I concluded that whatever is using your Babel config is not calling it asynchronously. In my case, it was jest 26. I got around the problem by changing the config to a JSON file - babel.config.json. Other people have changed their config file to a CommonJS file - babel.config.cjs. Then you will need to change your config file to be CommonJS, i.e., to use module.exports = {rest of your config}
.
The problem is that your package.json says you are using ES6 modules, but your Babel config is using module.exports
which is CommonJS (not ES6 modules).
Rename babel.config.js
to babel.config.cjs
.
To resolve the error "you appear to be using a native ecmascript module configuration file, which is only supported when running babel asynchronously," you can follow these steps: