Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Next.js and React

ESLint cannot load a config called react

ErrorFailed to load config "react" to extend from.

Short answer

A bare name in extends makes ESLint look for an npm package called eslint-config-react, which does not exist. The React rules come from the eslint-plugin-react package and are referenced as plugin:react/recommended. Install the plugin and change the extends entry. On ESLint 9 and later, use eslint.config.js instead.

  • Applies to ESLint 8, ESLint 9, eslint-plugin-react 7
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Check your ESLint version and which config file it reads. Version 9 uses eslint.config.js by default; older setups use .eslintrc files.

    npx eslint --version
    ls .eslintrc* eslint.config.* 2>/dev/null
  2. 2Match what you see, then jump to its fix

    1. 1Your .eslintrc has extends with the plain word reactextends uses react, not plugin:react/recommendedFix
    2. 2The extends value is already plugin:react/recommendedeslint-plugin-react is not installedFix
    3. 3ESLint 9 and a leftover string extends in a config fileAn eslintrc config used with ESLint 9 or laterFix

What does the error look like?

  • Failed to load config "react" to extend from.

Cause 1 of 3

extends uses react, not plugin:react/recommended

1Check

In eslintrc, an extends value that is an npm name is a shareable config. The React preset is part of the plugin.

grep -n -A4 "extends" .eslintrc*

2Fix

Use the plugin preset. Add the jsx-runtime preset as well when you use React 17 or later with the new JSX transform.

{
  "extends": [
    "eslint:recommended",
    "plugin:react/recommended",
    "plugin:react/jsx-runtime"
  ]
}

3Verify

Run ESLint.

npx eslint src

Confirmed by github.com

Did this fix it?

Cause 2 of 3

eslint-plugin-react is not installed

1Check

Look in node_modules.

npm ls eslint-plugin-react

2Fix

Install it as a development dependency.

npm install eslint eslint-plugin-react --save-dev

3Verify

Run ESLint.

npx eslint src

Confirmed by github.com

Did this fix it?

Cause 3 of 3

An eslintrc config used with ESLint 9 or later

1Check

Flat config is the default since ESLint 9.0.0 and drops string based extends. Configs are imported as modules.

ls eslint.config.*

2Fix

Import the plugin config and add it to the exported array.

// eslint.config.js
const js = require('@eslint/js');
const reactPlugin = require('eslint-plugin-react');

module.exports = [
  js.configs.recommended,
  reactPlugin.configs.flat.recommended,
  reactPlugin.configs.flat['jsx-runtime'],
];

3Verify

Run ESLint.

npx eslint src

Confirmed by eslint.org

Did this fix it?

How do I stop it coming back?

  • Use plugin: prefixed names for any config that comes from a plugin.
  • Set settings.react.version to detect so the plugin reads the installed version.
  • Pin ESLint's major version, and read the migration guide before you raise it.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Web apps

ESLint cannot parse your JSX or modern syntax

Parsing error: Unexpected token =

ESLint's built-in parser reads JSX only when ecmaFeatures.jsx is on, and it only lints file types your config lists.

3 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.