reactjscreate-react-appeslintbabel-eslint

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

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