Skip to content

Netlify and Vercel build errorThe app works in Bolt or Lovable, but the deploy build fails

It runs in the builder’s preview and on your laptop, then Netlify or Vercel stops with "Build failed" or "Command failed with exit code 1". The build machine is stricter than your laptop in four ways. Here’s how to find which one, or hand it over at a fixed price.

Short answer

Scroll up the build log to the first error, not the last line. Most often it’s a missing environment variable: Vite builds VITE_ variables into the code at build time, and Netlify doesn’t read .env files, so they must be set in the host’s settings. Next: a different Node version, a file name whose capital letters don’t match the import, or warnings treated as errors.

The four usual causes, and the fix

  1. 01

    Environment variables missing at build time

    Vite replaces VITE_ variables with their values when it builds, so they have to exist on the build machine. Netlify doesn’t read .env files during builds: add each variable in the site’s settings with the Builds scope. On Vercel, changed variables apply only to new deployments, so redeploy after adding them. Only put public values in VITE_ variables, since they end up in the browser.

  2. 02

    A different Node version

    The build machine uses its default Node version, which may not match yours. On Netlify, set a NODE_VERSION environment variable or add a .nvmrc file. On Vercel, set the Node.js version in the project’s build settings, or engines.node in package.json, which overrides the project setting.

    // package.json (Vercel)
    "engines": { "node": "22.x" }
    
    # .nvmrc (Netlify)
    22
  3. 03

    File name case doesn’t match the import

    Mac and Windows treat Button.tsx and button.tsx as the same file; Netlify’s build machine doesn’t. An import that works on your laptop fails there, and Netlify warns the error may not say so. Match every import to the file’s exact name. To rename a file’s case, use git mv so Git records the change.

  4. 04

    Warnings treated as errors, or peer dependency conflicts

    Netlify sets CI=true, and some tools then fail the build on warnings. Netlify’s fix is to start the build command with CI='' (CI=false may not work). For "Could not resolve dependency" or "Conflicting peer dependency" errors, Netlify’s fix is an NPM_FLAGS environment variable set to --legacy-peer-deps. Also confirm the publish directory matches your build output folder (dist for a default Vite app).

Checked against the vendor’s docs on : Vite docs: Env variables and modes; Netlify docs: Environment variables; Netlify docs: Manage build dependencies (Node.js version); Netlify docs: Build troubleshooting tips; Vercel docs: Environment variables; Vercel docs: Node.js versions.

Rather hand it over?

Fixed scope, fixed price, paid upfront. The work happens in writing; no call needed.

Related: Page not found on refresh · Lovable, Bolt and Replit app fixes

Questions

More on this error

Should I commit my .env file so the build can read it?

No. Keep .env out of Git and add the variables in Netlify’s or Vercel’s settings instead. Never put a secret such as a Supabase service_role key or a Stripe secret key in a VITE_ variable, because Vite builds those into code anyone can read.

The build passes but the live site is blank. Why?

Usually a VITE_ variable was missing at build time, so the app starts with an undefined URL or key and stops. Open the browser console on the live site, add the missing variable in the host’s settings, and redeploy.

Can I fix it inside Bolt or Lovable instead?

Sometimes. Ask the builder to fix the exact first error from the build log, then run the production build command locally (usually npm run build) before deploying again. If it keeps coming back, the same error is worth fixing by hand.

Can you fix it for me?

If one bug is the whole problem, the App Fix Ticket covers it: a written diagnosis first, then the fix. If the app has more going on, the Launch Check is a written check of the whole app. Each issue found is rated critical, high, medium or low, with where it is and how it was confirmed. No issues worth fixing, no charge. If the Launch Check finds nothing rated medium or higher, Simon refunds the full $450. You keep the report either way.

A different error?

Describe it and get a written quote

Send the error and what you were doing. You get a written scope, a fixed price and a timeline; we reply by email, usually within one business day.