"Build failed" on Vercel: fixing deploy errors in AI-built apps
Your Lovable, Bolt or Cursor project builds fine in the editor but Vercel says "Command 'npm run build' exited with 1". How to read the log and fix the usual causes.
Building a new app instead? Try Bolt (20% off with our link) (affiliate link).
Why it happens
Vercel runs a clean install and production build on Linux. Things the editor's preview tolerates can fail there: TypeScript type errors, ESLint errors treated as failures, missing packages that were only installed locally, or imports whose letter case does not match the file name.
Lockfile problems are common when a project moved between tools: two lockfiles (package-lock.json and bun.lockb or pnpm-lock.yaml), or a lockfile out of sync with package.json.
Wrong project settings also cause failures: the wrong Framework Preset, Output Directory (dist for Vite, .next for Next.js), Root Directory, or an old Node.js version.
How to fix it, step by step
- Open the failed deployment in Vercel and scroll the Build Logs to the first red error, not the last line. The first error is the real cause.
- If it says "Module not found" or "Cannot find module", check the package is in package.json and the import path matches the file name exactly, including capital letters.
- If it is a type error, fix the reported line, or ask your AI tool to fix only that error.
- Keep only one lockfile for the package manager you use and delete the others.
- In Project → Settings → Build and Deployment, check Framework Preset, Build Command, Output Directory and Root Directory. Set Node.js to a current LTS version.
- Run npm install and npm run build locally (or ask your AI tool to) to reproduce before pushing again.
Paste-ready prompt for Lovable
My Vercel deployment fails. Here is the first error from the build log: <paste the first red error and ~20 lines around it> Please: 1. Explain the cause in plain English. 2. Fix only that error with the smallest change (no refactors). 3. Check for import paths whose capitalization does not match the actual file names. 4. Make sure every imported package is listed in package.json, and that there is only one lockfile. 5. Tell me if any Vercel project settings (framework, output directory, Node version) need to change.
FAQ
It builds in Lovable. Why not on Vercel?
Vercel does a fresh, strict production build on a case-sensitive Linux system, so it catches errors a live preview can skip.
Can I just disable type checking?
It can get you deployed, but it hides real bugs. Fix the reported error when you can.
Still broken?
Get a free diagnosis by email within 24 hours. Fixed or refunded.
Get a free diagnosisOr get the weekly fix digest:
Free: the Vibe-Code Fix Checklist.