'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



Solution 1:[1]

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"
}

Solution 2:[2]

In my case solution was just run npm install eslint --save-dev for update eslint version

Solution 3:[3]

yarn add eslint --save-dev solved that issue for me!

Solution 4:[4]

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",

Solution 5:[5]

A little late here but thought I would share what got me going...

I completely dismissed the error output which tells me where the .eslintrc file (that is looking for said package) lives. As you can see... I had some random .eslintrc living outside of my project which was somehow getting picked up.

Failed to load parser 'babel-eslint' declared in '../.eslintrc': Cannot find module 'babel-eslint'

Solution:

Deleting this package ended up fixing the error for me. Not sure how that file got there but by mistake in a previous project.

I suspect that it has something to do with installing babel-eslint and eslint globally.

Solution 6:[6]

For me, it is because that dependency is really not installed... I just followed the GatsbyJS's official guide, and it is not installed (not sure why that guide is not complete).

So just: yarn add -D babel-eslint

Solution 7:[7]

? yarn add -D babel-eslint 
yarn add v1.22.15
[1/4] Resolving packages...
warning [email protected]: babel-eslint is now @babel/eslint-parser. This package will no longer receive updates.

babel-eslint seems deprecated and package is now provided as an ES module under babel, so remove babel-eslint and instead install @babel/eslint-parser

yarn remove babel-eslint
yarn add -D @babel/eslint-parser

Solution 8:[8]

Running eslint on your projects root folder eslint . will display the missing packages that you might need to install and that worked well for me.

Solution 9:[9]

Just add @babel/eslint-parser in .eslintrc

Solution 10:[10]

As for me i simply install this npm install [email protected] babel-eslint@8 - g and it works for me

Solution 11:[11]

run npm install eslint babel-eslint -D