ESLint cannot load the react plugin (eslint-plugin-react missing)
Failed 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.
Fix it fast
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.json2Match what you see, then jump to its fix
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-plugin2Fix
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-dev3Verify
Run ESLint again on a source folder; the load error should not appear.
npx eslint src/Confirmed by github.com
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 --all2Fix
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-dev3Verify
Run the lint script from that app folder.
npm run lintConfirmed by eslint.org
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:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
- WorkforceA field app, an admin console and a self-hosted Node.js server for push and reconciliation.
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 fixWeb apps
React shows Attempted import error when importing a component or function
Attempted import error:
The build found the file but not the name you asked for.
2 causes, each with a fixWeb apps
AxiosError Network Error with code ERR_NETWORK in a React app
Network Error
ERR_NETWORK means the request produced no readable response.
4 causes, each with a fixWeb apps
Axios get works with a URL string but ignores the object passed as the second argument
The server log shows a GET with no query string
axios.get takes a URL and an optional config object.
3 causes, each with a fixWeb apps
Can't resolve '../axios' in a React project
Module not found: Error: Can't resolve '../axios'
A path that starts with ./ or ../ is a file path, not the axios package.
3 causes, each with a fixWeb apps
Axios returns 401 from a React app but the login works elsewhere
Error: Request failed with status code 401
A 401 means the server received the request without valid credentials.
3 causes, each with a fix