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.

Vercel build log
Error: Command "npm run build" exited with 1

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 -b before vite build and next build checks 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_ or VITE_ values, aren’t set in Vercel.
  • Vercel uses a different Node.js version than your machine.

How to fix it

  1. Open the failed deployment, expand the build logs, and scroll up to the first error above this line.
  2. Run npm ci && npm run build locally to reproduce the build from a clean install.
  3. 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.
  4. Add missing environment variables in Project → Settings → Environment Variables for the right environment, then redeploy.
  5. Match Node.js versions with engines.node in package.json or the Node.js Version setting in your Vercel project.
All errors
./src/app/page.tsx:2:1 Module not found: Can't resolve '@/components/Header'

Module 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.

src/App.tsx:14:22 - error TS2339: Property 'title' does not exist on type 'Todo'.

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.

npm error code ERESOLVE npm error ERESOLVE unable to resolve dependency tree npm error npm error While resolving: my-app@0.1.0 npm error Found: react@19.2.0 npm error node_modules/react npm error react@"^19.2.0" from the root project npm error npm error Could not resolve dependency: npm error peer react@"^16.8.5 || ^17.0.0 || ^18.0.0" from react-beautiful-dnd@13.1.1 npm error node_modules/react-beautiful-dnd npm error react-beautiful-dnd@"^13.1.1" from the root project npm error npm error Fix the upstream dependency conflict, or retry npm error this command with --force or --legacy-peer-deps npm error to accept an incorrect (and potentially broken) dependency resolution.

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.

FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory

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.