Skip to content
Latchkey

Vercel "Command failed with exit code 1" build in CI

Vercel ran your configured build command and it returned a non-zero exit code, so the build stops. The real failure is in the build log above this summary line, not in Vercel itself.

What this error means

The Vercel build log ends with "Error: Command \"npm run build\" exited with 1" (the quoted command matches your build script).

Vercel
Error: Command "npm run build" exited with 1

Common causes

The build script itself failed

A type error, a failing lint, or a thrown exception during the build returned exit code 1, which Vercel surfaces as a failed command.

A missing dependency or env var at build time

The build references a package or environment variable that is present locally but absent in the Vercel build environment.

How to fix it

Read the build log above the summary

  1. Scroll up to the first error printed by the build command.
  2. Reproduce it locally with the same command and Node version.
  3. Fix the underlying error, then redeploy.

Provide missing build env vars

Add any environment variables the build needs in Vercel project settings or pass them in CI, and pin the Node version to match local.

vercel.json
# vercel.json
{
  "build": { "env": { "NODE_VERSION": "20" } }
}

How to prevent it

  • Run the exact build command in CI before deploying to catch failures early.
  • Keep build-time env vars defined in project settings.
  • Pin the Node version so local and Vercel builds match.

Frequently asked questions

What causes "Vercel "Command failed with exit code 1""?
A type error, a failing lint, or a thrown exception during the build returned exit code 1, which Vercel surfaces as a failed command.
How do I fix Vercel "Command failed with exit code 1"?
Read the build log above the summary

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card