Vercel: Command "npm run build" exited with 1, the real error
Vercel's "Command npm run build exited with 1" only says the build failed. The cause sits a few lines higher in the build log. How to find and fix it.
Short answer
Error: Command "npm run build" exited with 1 on Vercel means your own build script stopped with an error. The line itself carries no cause. Vercel's troubleshooting guide says the last mention of "Error" is often not the useful one, and that the real error sits a few lines above it in the build log.
Open the failed deployment, expand Building under Deployment Details, scroll up from the red exit line, fix what that line names, and push again. In apps written by an AI agent the cause is usually a TypeScript error, an import whose letter case differs from the file name, or a variable the build needs but the project does not have.
Where the useful line is
Here is a trimmed log from a Next.js app we will call Tallyhound. The last two lines are what people paste into a search box. The line that matters is the one naming a file and a line number.
Running "npm run build"
> tallyhound@0.1.0 build
> next build
Creating an optimized production build ...
Compiled successfully
Failed to compile.
./app/invoices/[id]/page.tsx:18:22
Type error: Property 'totalCents' does not exist on type 'Invoice'.
Error: Command "npm run build" exited with 1Reproduce it before you change anything
Vercel recommends building on your own machine first, because most failures are in the code or its dependencies, not in Vercel. Run a clean install and the same build command the project uses. If it fails locally with the same message, you can fix it in your editor and stop guessing.
If it passes locally, build the way Vercel does. vercel pull downloads the project settings and environment variables into .vercel/, and vercel build then runs the build locally with them. By default it uses Preview variables; add --prod to use Production ones. A failure that only appears with vercel build points at settings or variables rather than code.
# 1. the plain build, from a clean install
rm -rf node_modules .next
npm ci
npm run build
# 2. the build with Vercel's settings and variables
npx vercel pull --yes --environment=production
npx vercel build --prodMatch the line above the exit code
| What the earlier line says | Likely cause | Fix |
|---|---|---|
Type error: ... with a file and line | Next.js fails next build on TypeScript errors | Fix the type, or regenerate types after a schema change |
Module not found: Can't resolve './components/usercard' | Import casing differs from the file name; Vercel builds on case-sensitive Linux | Match the casing and commit the rename |
It looks like you're trying to use TypeScript but do not have the required package(s) installed | NODE_ENV=production set as a project variable, so devDependencies were skipped | Delete that variable or use npm install --include=dev |
| An error thrown while collecting page data, naming a missing key or URL | Code reads a variable at build time that the environment does not have | Add it for the environment being built, then redeploy |
A complaint that a webpack configuration was found | Next.js 16 builds with Turbopack by default and refuses a custom webpack config | Use next build --webpack or migrate the config |
npm ci fails before the build starts | package-lock.json is out of step with package.json | Run npm install locally and commit the lockfile |
Five causes that keep coming back in AI-written apps
Coding agents write a lot of code quickly and rarely run a production build before they stop. These are the failures that follow from that habit.
- Type errors.
next devshows the page even when types are wrong, but the Next.js docs state that a production build fails when TypeScript errors are present. An agent that renamed a database column often leaves one component using the old field name, as in the Tallyhound log. Thetypescript.ignoreBuildErrorsoption exists, but switching it on only moves the bug to your users. - Letter case in imports. Windows and macOS treat
UserCard.tsxandusercard.tsxas the same file, while Vercel builds on a case-sensitive Linux file system. Git on your machine may not even record a case-only rename. Vercel's guide suggests renaming through a temporary name withgit mvso the change is committed. - Variables read at build time. Anything that runs while pages are prerendered, such as a database query in a server component or a client created at the top of a module, runs inside the build. If the variable is set only for Preview, or only in your local
.env.local, the production build cannot see it. - Node.js version drift. As of December 2026 Vercel offers Node.js 26.x (the default for new projects), 24.x and 22.x, chosen under Settings, Build and Deployment, or through
engines.nodeinpackage.json, which overrides the setting. Next.js 16 needs at least 20.9, so an old pin inenginesbreaks it. - Development dependencies skipped. Vercel installs devDependencies by default, but your project variables are present during install. If someone added
NODE_ENV=productionas a variable, npm skips devDependencies and the build losestypescript. Next.js setsNODE_ENVitself during a build, so the variable is rarely needed.
When the build is cancelled rather than failed
A cancelled build is a different problem from an exit code of 1. Vercel cancels a build that runs past 45 minutes or exceeds the memory or disk of its build machine. Hobby teams always use the Basic machine with 2 vCPUs and 8 GB of memory. When a limit is reached, Vercel adds a system report to the build log, and setting VERCEL_BUILD_SYSTEM_REPORT=1 produces that report on every build. Heap out-of-memory errors in next build have their own causes and fixes, covered in a separate article.
Some failures produce no build log at all. Vercel lists an invalid vercel.json, an Ignored Build Step, a commit from someone who is not a team member, and a Marketplace integration that failed to provision. In those cases the dashboard shows an overlay with the message instead of the Building section.
Rule out the cache
A successful build updates the build cache and a failed one leaves it unchanged, so a broken cache is uncommon. When a build fails for no reason you can see, redeploy without it. In Deployments, open the menu next to the deployment, choose Redeploy and leave Use existing Build Cache unticked. From the CLI, vercel --force builds without the cache, and the variable VERCEL_FORCE_NO_BUILD_CACHE=1 skips restoring it on every build.
Confirm the fix and keep it fixed
The fix is confirmed when the deployment reaches Ready and the page that broke the build renders on the deployment URL. Then make the failure cheaper next time. Add npm run build to whatever runs before you push, for example a CI job on pull requests, so a type error stops in a branch rather than on the production deployment. Ask your coding agent to run the production build and fix every error before it reports a task as done; a line in its instructions file is enough.
Keep the variables your build needs listed in .env.example, with empty values, so a missing one is visible in review. And keep one lockfile in the repository, for the package manager the project actually uses. For a wider checklist of what agents skip before production, see the guide on going from vibe coding to production.
Where Shipyard fits
Shipyard creates the Vercel project with the framework preset and the GitHub repository attached, and writes the production and preview variables before the first build runs, which removes the missing-variable cause. It also writes a build prompt for your agent. Type errors and import casing stay in your code, so the local build above is still the quickest check.
Sources
- Vercel docs: Troubleshooting build errorsvercel.com
- Vercel knowledge base: How do I resolve a 'module not found' error?vercel.com
- Vercel docs: Supported Node.js versionsvercel.com
- Vercel docs: Managing builds (build machines)vercel.com
- Vercel docs: vercel buildvercel.com
- Next.js docs: typescript (ignoreBuildErrors)nextjs.org
- Next.js docs: Upgrading to version 16nextjs.org
Launch in an hour, not a weekend
Shipyard connects your accounts once, then sets up the domain, hosting, database, email and payments for every new product.