Create React App stops compiling because of an ESLint rule
npm start or npm run build stops with an ESLint problem listed by file and lineShort answer
Create React App runs ESLint inside its webpack build. Any rule set to error stops the build, and when CI is true even warnings count as failures. Fix the reported line first. If you must keep working, ESLINT_NO_DEV_ERRORS turns dev errors into warnings, and DISABLE_ESLINT_PLUGIN turns the plugin off.
Fix it fast
1Find out which cause you have
Run ESLint on its own. It prints the file, the line and the rule name for every problem, without waiting for the bundler.
npx eslint src2Match what you see, then jump to its fix
- 1
The failing rule is one you added or changed in package.json or an eslint config fileA rule is set to error in your eslintConfigFix - 2
Works locally, fails in the pipeline, and the failing items are warningsCI is true, so warnings fail the buildFix - 3
The browser shows the error overlay for lint errors in developmentYou need the dev server to keep running while you fix thingsFix - 4
The error comes from a rule in a vendor or generated folder you cannot editThe ESLint plugin itself must be off, for example in a build you do not ownFix
- 1
What does the error look like?
npm start or npm run build stops with an ESLint problem listed by file and linethe browser shows an error overlay for a lint rule in developmentthe build fails only on the CI server and passes on your machine
Cause 1 of 4
A rule is set to error in your eslintConfig
1Check
The docs say any rule set to error stops the project from building. Look at what you override.
grep -n -A12 "eslintConfig" package.json2Fix
Fix the code the rule reports. If the rule is wrong for your project, lower it to warn instead of removing the base config, which the docs advise against.
"eslintConfig": {
"extends": ["react-app"],
"rules": {
"no-unused-vars": "warn"
}
}3Verify
Run the build again.
npm run buildConfirmed by create-react-app.dev
Cause 2 of 4
CI is true, so warnings fail the build
1Check
The CRA docs say that with CI set to true, build warnings count as failures. Most CI systems set it.
echo "CI=$CI"2Fix
Fix the warnings. As a temporary measure only, build with CI off for that one command.
CI=false npm run build3Verify
The pipeline passes, and then you remove the CI=false override after fixing the warnings.
npm run buildConfirmed by create-react-app.dev
Cause 3 of 4
You need the dev server to keep running while you fix things
1Check
ESLINT_NO_DEV_ERRORS=true shows ESLint errors as warnings in development and removes them from the overlay. It applies to development only.
cat .env 2>/dev/null2Fix
Add the variable to a .env file in the project root and restart. Fix the underlying errors afterwards, since production builds still see them.
# .env
ESLINT_NO_DEV_ERRORS=true3Verify
Restart the dev server; the overlay is gone and the lint output shows warnings.
npm startConfirmed by create-react-app.dev
Cause 4 of 4
The ESLint plugin itself must be off, for example in a build you do not own
1Check
DISABLE_ESLINT_PLUGIN=true turns the webpack ESLint plugin off completely, in development and production.
grep -rn "DISABLE_ESLINT_PLUGIN" .env package.json2Fix
Set it for the command that needs it, and keep linting in a separate step so problems are still found.
DISABLE_ESLINT_PLUGIN=true npm run build3Verify
The build finishes. Run npx eslint src separately to keep the checks.
npx eslint srcConfirmed by create-react-app.dev
How do I stop it coming back?
- Run npx eslint src in your pre-commit step so CI never sees a new lint failure first.
- Set the same CI value locally when you test a production build.
- Use warn for style rules and keep error for rules that catch real bugs.
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
A build that passes locally fails on Netlify because of warnings
The log shows warnings, and the build stops on them
Netlify sets CI=true for every build.
2 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