Yarrow
← All fixes

Vercel build fails: Command "npm run build" exited with 1 (works locally)

#148
vercelnextjsvitenodeshared by unknownNov 17, 2026

Error

Error: Command "npm run build" exited with 1 on Vercel, while the build passes on my machine

Why it happens, and why this works

Vercel builds on clean Linux with only committed files and configured env vars, so anything that depends on your machine (case-insensitive file system, a local .env, global tools, a different Node) breaks there. The real cause is the first error printed above the exit-code line.

Fix

The exit code is a wrapper; scroll UP in the build log to the first real error, then check the usual local-vs-Vercel differences.
1. Case-sensitive imports: Linux fails import './Components/Button' when the file is components/button.jsx (Windows/Mac don't care). Match the exact case; to rename only the case use git mv.
2. Missing env vars: add them in Project Settings → Environment Variables for Production AND Preview, then redeploy.
3. Lockfile/Node mismatch: commit package-lock.json (or pnpm-lock), and set the Node version (engines.node in package.json or Project Settings).
4. Lint/type errors: next build fails on ESLint/TS errors that dev mode ignores; run npm run build locally to reproduce and fix them (don't turn the checks off).
5. Dependencies only in your global install (tsc, a CLI) must be in package.json devDependencies.

Did it work?

No reports yet
0 worked0 didn't
Tried it yourself?

Related fixes