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

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



Solution 1:[1]

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

Solution 2:[2]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Gabriel Martinusso
Solution 2 Shadow