Vercel Build Exited With 1 — Fix Deploy Failures
Build fails on Vercel with exit code 1. Almost always a missing dependency or config issue. Here's the exact fix.
Quick answer
Run npm install locally, check your package.json for missing deps, and ensure your build command matches your framework (e.g., next build for Next.js). If that doesn't work, delete node_modules and package-lock.json, then rebuild.
What's happening
That build exited with 1 error on Vercel is the most common deployment failure I've seen. It means your build script returned a non-zero exit code — something crashed. The culprit is almost always a dependency issue: a package that installs fine locally but fails on Vercel's servers. Maybe it's a native module that needs a specific OS package, or you're missing a dev dependency that should be a regular dependency. Sometimes it's a misconfigured build command, like trying to run next build without having Next.js listed in dependencies.
I've fixed this for dozens of projects running Next.js, React, Vue, and SvelteKit. The fix is straightforward, but you need to check the build logs. Vercel shows you the actual error output — read it carefully. It'll point you straight at the issue.
Fix steps (numbered)
- Check the build logs. Go to your Vercel dashboard, click the failed deployment, and scroll to the error. Look for lines like
Module not found,Cannot find module, orcommand not found. That's your clue. - Verify package.json. Open your
package.json. Make sure all packages you import are listed underdependencies(notdevDependencies). Vercel by default only installsdependenciesfor production builds. If you use a tool like Tailwind CSS or PostCSS, they need to be independenciesunless you setVERCEL_NPM_DEV_DEPENDENCIES. - Run a fresh install locally. Delete
node_modulesandpackage-lock.json(oryarn.lock). Then runnpm installagain. This mimics what Vercel does. If it fails locally, you'll see the same error. Fix it there first. - Check your build command. In your Vercel project settings, the build command must match your framework. For Next.js, it's
next build. For React with Create React App, it'sreact-scripts build. If you're using a monorepo, you might needcd app && next build. - Pin Node version. In
package.json, add"engines": { "node": "18.x" }. Or set it in Vercel's project settings under Node.js Version. I've seen builds fail because a newer Node version broke a package. - Use a .vercelignore file. If you have large files or folders that shouldn't be uploaded (like
.git,node_modulesalready gets ignored, but add*.local), create a.vercelignorefile and list them. This prevents weird upload issues. - Test with a fresh deploy. Push a small change, like adding a comment in your main file, and redeploy. Sometimes Vercel caches a bad build. A new push forces a clean build.
Alternative fixes if the main ones fail
If those steps don't work, try these:
- Switch package manager. Delete
package-lock.jsonandnode_modules. Then runyarn install(if you have a yarn.lock). Vercel supports npm, yarn, and pnpm. Sometimes npm's lockfile causes issues. Useyarnorpnpm. - Set VERCEL_NPM_DEV_DEPENDENCIES. In Vercel environment variables, add
VERCEL_NPM_DEV_DEPENDENCIES=1. This forces Vercel to install devDependencies too. Helpful for build tools like esbuild or TypeScript that need to be available during build. - Use a custom install command. In Vercel project settings, set the Install Command to
npm ciinstead ofnpm install. Thecicommand uses the lockfile exactly, no updates. This catches lockfile mismatches. - Check for native modules. If you're using
sharp,bcrypt, or similar, they need native compilation. Vercel supports that, but you might need to add apostinstallscript. For sharp, add"postinstall": "sharp-cli --check"in package.json. - Review your vercel.json. If you have a
vercel.jsonfile with custom build or install commands, double-check the syntax. A typo there will cause a failure. Example:{ "buildCommand": "next build" }— make sure it's valid JSON.
Prevention tip
The best way to avoid this is to test your build locally before pushing. Run the exact same build command that Vercel uses. For Next.js, that's next build. For a CRA app, it's react-scripts build. If it passes locally 99% of the time, it'll pass on Vercel. Also, always keep your lockfile in version control — don't add it to .gitignore. Vercel uses it to reproduce your install exactly. Finally, set up a CI pipeline (like GitHub Actions) that runs the build on every push. That catches issues before they reach production.
Was this solution helpful?