Problem with babel-esLint: Parsing error: require() of ES Module

Viewed 10090

Hello. I need your help. How can I fix this error?

Parsing error: require() of ES Module Desktop/Projects/MealsToGo/node_modules/eslint-scope/lib/definition.js from Desktop/Projects/MealsToGo/node_modules/babel-eslint/lib/require-from-eslint.js not supported. Instead change the require of definition.js in Desktop/Projects/MealsToGo/node_modules/babel-eslint/lib/require-from-eslint.js to a dynamic import() which is available in all CommonJS modules

3 Answers

This is probably happening because you, like me, were using the old babel parser.

Just change and install or update to the lastest parser packaged in .eslintrc.js:

old .eslintrc.js:

module.exports = {
 parser: 'babel-eslint',
 ...
};

new .eslintrc.js

module.exports = {
 parser: '@babel/eslint-parser',
 ...
};

Note:

babel-eslint has been deprecated sinse Mar 2020. The package was migrated to new repo, if you want to know more i recommend you check Babel git :D

Another cause of this issue is an old node version.

I was getting this with ESLint 8.10.0 and Node 12. Upgrading Node to 14 was the fix.

This is the solution: module.exports = { parser: '@babel/eslint-parser', ... };

Related