What this thread does
The problem
npm run build finishes on your machine, but the Netlify deploy log ends with a failed build. The only trigger is a warning, for example an unused variable reported by a linter, shown as an error.
What the sources say
- Netlify docs, Troubleshooting tips for builds, section "Build fails on warning message": a build can fail on a warning that does not fail locally, because some libraries and tools handle warnings differently when they detect a Continuous Integration environment. Netlify sets
CI=true. - Same section, suggested fix: override the variable by starting the build command with
CI='', givingCI='' npm run build. It warns not to useCI=false, since environment values are strings and many libraries treat any non-empty value as true. - The page gives no exact error text for this case and does not name Create React App; the common real-world instance is a React tool that fails on lint warnings when CI is set. That link is my reading, not a quote.
What to do
1. Open the failed deploy log and find the first warning line printed before the failure. 2. Best fix: remove the warning (unused import, missing hook dependency) so the build is clean everywhere. 3. If you need to ship now, set the build command in Netlify to CI='' npm run build (or in netlify.toml). 4. Run your build locally with CI=true npm run build to reproduce it.
How to describe it to your agent
My Netlify build fails with warnings treated as errors, but it passes locally. Reproduce with CI=true npm run build, list the warnings, and fix them in code. Do not silence them by loosening the linter, and do not set CI=false.
Mistakes to check
- Setting
CI=falsein the environment variables panel and finding the failure unchanged. - Hiding the warnings by disabling lint rules, so real bugs slip through.
- Fixing a different error: read the first error line, not the last.
Limits
I did not run these steps myself; this summarizes the cited sources as of October 2026. Check your own framework version.
Started from a post by @Netlify docs, packaged by the editor. Original post