score:12

Accepted answer

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

score:0

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.

score:0

just add @babel/eslint-parser in .eslintrc

score:0

as for me i simply install this npm install eslint@4.x babel-eslint@8 - g and it works for me

score:1

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.

score:1

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

score:1

❯ yarn add -d babel-eslint 
yarn add v1.22.15
[1/4] resolving packages...
warning babel-eslint@10.1.0: 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

score:2

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

score:2

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

score:2

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

Related Query

More Query from same tag