Maaz Zindani

Loading the index…

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

ESLint cannot load the react plugin (eslint-plugin-react missing)

ErrorFailed to load plugin 'react' declared in '.eslintrc': Cannot find module 'eslint-plugin-react'

Short answer

ESLint loads a plugin by name, as if the config file required eslint-plugin-react itself. The error means that package cannot be found from where the config lives. Install eslint-plugin-react as a local dev dependency in the project folder that holds the ESLint config, then run ESLint again.

  • Applies to ESLint 8 (.eslintrc), eslint-plugin-react (current release), Node.js 22
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Check whether the package exists in the same project as the ESLint config, and which config file names the plugin.

    npm ls eslint-plugin-react
    grep -n "react" .eslintrc* package.json
  2. 2Match what you see, then jump to its fix

    1. 1npm ls prints (empty) or no match for eslint-plugin-reacteslint-plugin-react was never installedFix
    2. 2The plugin exists in some other node_modules (a parent, a sibling package, a shared config) but not where the config is resolved fromThe config is in a different folder than the installFix

What does the error look like?

  • Failed to load plugin 'react' declared in '.eslintrc': Cannot find module 'eslint-plugin-react'

Cause 1 of 2

eslint-plugin-react was never installed

1Check

A config line such as plugins: ["react"] or extends: ["plugin:react/recommended"] only names the plugin. ESLint says to install the plugin with npm before using it, and the name react maps to the package eslint-plugin-react.

ls node_modules | grep eslint-plugin

2Fix

Install ESLint and the plugin together as local dev dependencies. The plugin's own docs advise a local ESLint install over a global one.

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

3Verify

Run ESLint again on a source folder; the load error should not appear.

npx eslint src/

Confirmed by github.com

Did this fix it?

Cause 2 of 2

The config is in a different folder than the install

1Check

Plugins are resolved relative to the config file. When a config is pulled in through extends, plugins are resolved relative to the config that is extending it, so ESLint searches ./node_modules and its ancestors, not the shared config's own node_modules.

ls -a | grep -i eslintrc
npm ls eslint-plugin-react --all

2Fix

Add eslint-plugin-react to the dependencies of the project whose config is used (the app, not only the shared config package), or install it at the workspace root so ancestor lookup finds it.

cd path/to/the-app-with-the-.eslintrc
npm install eslint-plugin-react --save-dev

3Verify

Run the lint script from that app folder.

npm run lint

Confirmed by eslint.org

Did this fix it?

How do I stop it coming back?

  • Whenever you add plugin:react/recommended to a config, install eslint-plugin-react in the same commit.
  • In a monorepo, list the plugin in every app that extends the shared config.
  • Run the lint script in CI so a missing package fails the build, not a teammate's editor.

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 load a config called react

Failed to load config "react" to extend from.

A bare name in extends makes ESLint look for an npm package called eslint-config-react, which does not exist.

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.