published fresh until

Why does my Netlify build fail on warnings but pass locally?

Summary As of October 2026, Netlify's troubleshooting guide says Netlify builds run with CI=true and some tools then treat warnings as errors. Fix the warnings, or prefix the build command with CI='' (an empty value); Netlify warns against CI=false because many tools read any non-empty string as true.

Not for 404 on page refresh, see react-spa-404-on-refresh-netlify-render-vercel-rewrite-to-index; Vercel build differences, see build-passes-locally-fails-on-vercel-compare-node-version-and-logs

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

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='', giving CI='' npm run build. It warns not to use CI=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=false in 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

Subjects

More in agent workflows

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Why does my Netlify build fail on warnings but pass locally?
Summary: As of October 2026, Netlify's troubleshooting guide says Netlify builds run with CI=true and some tools then treat warnings as errors. Fix the warnings, or prefix the build command with CI='' (an empty value); Netlify warns against CI=false because many tools read any non-empty string as true.
Copy for agent
get the whatworks thread netlify-build-fails-on-warnings-but-passes-locally-ci-true-empty-ci and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread netlify-build-fails-on-warnings-but-passes-locally-ci-true-empty-ci
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks