Vercel "Command "npm run build" exited with 1" - Fix in CI
Vercel ran your build command and it exited non-zero. The failure is inside your build - a TypeScript error, a failing import, or a missing environment variable - not in Vercel’s platform.
What this error means
The deploy stops with Command "npm run build" exited with 1. The real error is higher in the build log: a compile error, a missing env var the build reads, or a dependency that failed. It reproduces locally with the same command.
Error: Command "npm run build" exited with 1
> tsc && vite build
src/app.tsx:14:22 - error TS2304: Cannot find name 'API_URL'.Common causes
A real build error
A type error, failing import, or test that runs during build makes the script exit 1. Vercel just surfaces the non-zero exit; the cause is above it in the log.
Missing build-time environment variable
The build reads an env var that is set locally but not configured in the Vercel project, so it fails only in the cloud build.
How to fix it
Reproduce and read the real error
Run the exact build locally and scroll above the exit line for the underlying error.
npm ci && npm run build # reproduce the same failure locallyConfigure build-time env vars in Vercel
- Add the missing variable in Project Settings → Environment Variables for the right environment (Production/Preview).
- For client-exposed values, use the framework’s public prefix (e.g.
VITE_,NEXT_PUBLIC_). - Redeploy after adding so the build picks up the new value.
How to prevent it
- Run the production build in PR CI so failures surface before the Vercel deploy.
- Keep required env vars documented and configured per Vercel environment.
- Pin Node and dependency versions so local and Vercel builds match.