Command "npm run build" exited with 1
Your build script failed on the host. This line only reports the failure; the actual error is printed earlier in the build log.
Also appears as
- Command failed with exit code 1: npm run build (https://ntl.fyi/exit-code-1)
- Failed: build command exited with code: 1
Prompt to fix it
My Vercel deploy fails with "Error: Command "npm run build" exited with 1". Here is the full build log: [paste the log]. Find the first real error above that line, explain it, and fix the cause in the code or config. Then run a clean install and the production build locally to confirm it passes. Check import casing against file names and any environment variables the build needs. Don’t disable type checking or linting, skip the build step, or add @ts-ignore to get it passing.
Paste into Layerwise or any AI coding tool.
What it means
Vercel runs your project’s build script, and exit code 1 is the generic signal for “something failed.” This last line is just the summary. The cause is printed above it: a TypeScript error, a missing module, a lint failure, or a crash in your build tool.
Scroll up from the bottom of the log to the first red line, or the first line that starts with Error, error TS, Failed to compile, or Module not found. That line and the file path near it are what to fix.
When the build passes on your machine but fails on Vercel, look at what differs. Vercel builds on Linux from a clean install. File names are case-sensitive there, so import Header from './header' fails when the file is Header.tsx, and values in your local .env don’t exist until you add them in the project settings.
Common causes
- Type errors the dev server never showed, because Vite’s template runs
tsc -bbeforevite buildandnext buildchecks types too. - An import whose letter casing differs from the file name, which works on macOS and fails on Linux.
- A package used in code but missing from
package.json, or a lockfile that’s out of sync with it. - Environment variables the build reads, such as
NEXT_PUBLIC_orVITE_values, aren’t set in Vercel. - Vercel uses a different Node.js version than your machine.
How to fix it
- Open the failed deployment, expand the build logs, and scroll up to the first error above this line.
- Run
npm ci && npm run buildlocally to reproduce the build from a clean install. - Fix what the error names: correct the type, match the import’s casing to the file name, or add the missing package with
npm install. - Add missing environment variables in Project → Settings → Environment Variables for the right environment, then redeploy.
- Match Node.js versions with
engines.nodeinpackage.jsonor the Node.js Version setting in your Vercel project.
Related errors
All errorsModule not found: Can't resolve
The bundler followed an import to a file or package that doesn’t exist under that name, so it couldn’t build the page.
Property does not exist on type
TypeScript can’t find that field on the type it has for this value, either because the type is wrong or because the value might not have it.
ERESOLVE unable to resolve dependency tree
npm stopped installing because a package only supports a different version of something your project already uses, most often React.
JavaScript heap out of memory
Node used up all the memory it’s allowed and crashed, usually during a large build or in code that keeps holding on to more and more data.
Build with an agent that checks its work
The Layerwise agent clicks through the live preview and reads the console, so it catches errors before you do.