Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: Failed to load parser 'babel-eslint' declared in '.eslintrc': Cannot find module 'babel-eslint' in create-react-app

Trying to install eslint into create-react-app, but get next error when running linter:

enter image description here]

Here is my .eslintrc config file:

{
  "extends": ["airbnb", "prettier", "prettier/react"],
  "plugins": ["prettier"],
  "parser": "babel-eslint"
}

If install babel-eslint manually it'll potentially produce another error based on package conflict between project and react-scripts dependencies: enter image description here

like image 587
Alexandr Tovmach Avatar asked Sep 05 '25 17:09

Alexandr Tovmach


2 Answers

Did you install @babel/eslint-parser or eslint-parser? In my case I had to use @babel/eslint-parser and .eslintrc looks like this:

"parser": "@babel/eslint-parser",
like image 51
Mahdiyeh Avatar answered Sep 09 '25 02:09

Mahdiyeh


To fix this issue just reuse babel-eslint dependency from react-scripts, that already installed. Update your config:

{
  "extends": ["airbnb", "prettier", "prettier/react"],
  "plugins": ["prettier"],
  "parser": "react-scripts/node_modules/babel-eslint"
}
like image 23
Alexandr Tovmach Avatar answered Sep 09 '25 04:09

Alexandr Tovmach