babel not trans compiling the files inside node_modules even with babel.config.js

26 views Asked by At

I was getting this error

SyntaxError: Cannot use import statement outside a module at Object.compileFunction (node:vm:352:18) at wrapSafe (node:internal/modules/cjs/loader:1033:15)

So I configured .babelrc with

{
    "presets": ["@babel/preset-env"],
    
}

While this resolved the issue in all the files, it couldn't for the ones which are inside node_modules

So I read some of the answers and it was recommended to change from .babelrc to babel.config.js to include all the directory including node_modules.

so I renamed .babelrc to babel.config.js with the following snippet:

module.exports = {
    presets: ["@babel/preset-env"],
    
}; 

However the issue still persists.

0

There are 0 answers