Originally published at unbreakkit.netlify.app.
The error
Error: Command "npm run build" exited with 1
The real cause is earlier in the build log. Scroll up to the first red line.
Common causes and fixes
1. TypeScript errors (the dev server tolerates them, but next build doesn't)
Type error: Property 'x' does not exist on type 'y'.
Run npm run build locally and fix each error. As a temporary measure only, you can skip the type check:
// next.config.js
module.exports = { typescript: { ignoreBuildErrors: true } };
Since Next.js 16, next build no longer runs ESLint, and the eslint option in next.config.js was removed. If your build still fails on lint errors, your build script runs a linter itself, so fix those errors or run lint as a separate step.
2. Missing environment variables
supabaseUrl is required. or undefined API keys. Add them in Vercel → Project → Settings → Environment Variables, then redeploy. Variables that are read in the browser need the NEXT_PUBLIC_ prefix.
3. Module not found (case sensitivity)
Vercel builds on Linux, so ./components/Header ≠ ./components/header. Fix the imports or rename the files. (In git, use git mv for case-only renames.)
4. Dependency conflicts
npm ERR! ERESOLVE unable to resolve dependency tree. Align versions in package.json. As a fallback, set the Install Command to npm install --legacy-peer-deps.
5. Errors while prerendering a page
Error occurred prerendering page "/dashboard". The page fetches data or uses window at build time. Move browser code into useEffect, or make the route dynamic:
export const dynamic = 'force-dynamic';
6. Wrong framework or output settings (common with Bolt/Vite apps)
For Vite, set Framework Preset to Vite, Build Command to npm run build, and Output Directory to dist. For client-side routing, add vercel.json:
{ "rewrites": [{ "source": "/(.*)", "destination": "/index.html" }] }
7. Node version mismatch
Vercel currently supports Node.js 24.x (the default) and 22.x. Node.js 20 was deprecated on October 1, 2026, so new deployments pinned to 20.x fail. Set the version in Project Settings → Build and Deployment, or add "engines": { "node": "24.x" } to package.json (this overrides the Project Settings value).
FAQ
Why does it work in the v0/Bolt preview? Previews run a dev server, which skips type checks and prerendering.
Do I need to redeploy after adding env vars? Yes. Existing deployments don't pick up new values.
Related guides
- Invalid API key or undefined env vars on Vercel
- Module not found: a checklist for AI-generated code
- npm ERESOLVE peer dependency errors
- Works in preview, blank page in production
Still stuck?
Paste your exact error into the free UnbreakKit Error Fixer and get a plain-English cause, the fix, and a prompt to paste back into your AI tool: https://unbreakkit.netlify.app/products/error-fixer.html
Top comments (0)