Maaz Zindani

Loading the index…

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

Create React App stops compiling because of an ESLint rule

Errornpm start or npm run build stops with an ESLint problem listed by file and line

Short 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.

  • Applies to react-scripts 5, Node.js 22
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 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 src
  2. 2Match what you see, then jump to its fix

    1. 1The 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. 2Works locally, fails in the pipeline, and the failing items are warningsCI is true, so warnings fail the buildFix
    3. 3The browser shows the error overlay for lint errors in developmentYou need the dev server to keep running while you fix thingsFix
    4. 4The 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

What does the error look like?

  • npm start or npm run build stops with an ESLint problem listed by file and line
  • the browser shows an error overlay for a lint rule in development
  • the 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.json

2Fix

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 build

Confirmed by create-react-app.dev

Did this fix it?

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 build

3Verify

The pipeline passes, and then you remove the CI=false override after fixing the warnings.

npm run build

Confirmed by create-react-app.dev

Did this fix it?

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/null

2Fix

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=true

3Verify

Restart the dev server; the overlay is gone and the lint output shows warnings.

npm start

Confirmed by create-react-app.dev

Did this fix it?

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.json

2Fix

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 build

3Verify

The build finishes. Run npx eslint src separately to keep the checks.

npx eslint src

Confirmed by create-react-app.dev

Did this fix it?

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:

Related fixes

Next step

Want this handled for good?

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