Next.js ESLint errors failing next build in CI
next build runs ESLint over your app and any lint error (not just a warning) fails the build with "Failed to compile". This is why a build can break on a rule violation that the dev server ignored.
What this error means
next build prints "Failed to compile." followed by ESLint output such as "Error: 'x' is defined but never used no-unused-vars" or a next/core-web-vitals rule, ending the job non-zero.
Failed to compile.
./app/page.tsx
12:9 Error: 'data' is assigned a value but never used. @typescript-eslint/no-unused-vars
info - Need to disable some ESLint rules? Learn more here:
https://nextjs.org/docs/app/api-reference/config/eslintCommon causes
ESLint reports an error-level rule during the build
Next runs lint as part of next build; any rule set to "error" fails compilation, unlike warnings which do not.
CI lints files that local runs skipped
A clean checkout lints the whole project, so a violation in a file you did not touch locally now fails.
How to fix it
Fix the reported lint errors
- Run
npx next lintto reproduce the exact errors CI sees. - Resolve each error, or apply autofixes with
npx next lint --fix. - Re-run next build to confirm lint passes.
npx next lint
npx next lint --fixAdjust rule severity deliberately
If a rule should not block builds, downgrade it to a warning in ESLint config rather than disabling lint entirely.
// eslint.config.mjs
rules: { '@typescript-eslint/no-unused-vars': 'warn' }How to prevent it
- Run next lint in CI as a separate step so failures are clear.
- Keep rule severities intentional rather than ignoring all lint.
- Avoid
eslint.ignoreDuringBuildsunless lint runs elsewhere.