Skip to content
Latchkey

Next.js ENOENT .next/build-manifest - Fix in CI

Next looked for .next/build-manifest.json and it is not there. A start/export step ran before next build, or a cache step restored a partial .next.

What this error means

A next start, export, or post-build step fails with ENOENT: no such file or directory, open '.next/build-manifest.json'.

next
Error: ENOENT: no such file or directory, open
'/app/.next/build-manifest.json'
    at Object.openSync (node:fs:600:3)

Diagnose it: is it resolution, transform, or memory?

Bundler failures in CI fall into three families and the error text often points at the wrong one. A module that resolves on your machine and not on the runner is nearly always case sensitivity or a missing optional dependency; a transform error is a config or version mismatch; and an unexplained kill with no stack is the out-of-memory reaper, not a build error at all.

Terminal
# 1. resolution: does the file exist with EXACTLY that case?
git ls-files | grep -i "the/imported/path"

# 2. transform: what versions is CI actually resolving?
npm ls webpack vite rollup esbuild typescript 2>/dev/null | head -20

# 3. memory: was it killed rather than failed?
#    exit 137 = SIGKILL (OOM). Nothing in the bundler log will explain it.
node --max-old-space-size=4096 node_modules/.bin/vite build

Common causes

Build step skipped or failed silently

next start/export ran without a successful next build first, so .next is missing or incomplete.

Partial .next cache restored

A CI cache restored a stale or incomplete .next directory missing the manifest.

How to fix it

Build before start/export

  1. Ensure next build runs and succeeds before any step that reads .next.
Terminal
npm run build && npm run start

Stop caching the full .next output

  1. Cache only the Next build cache, not the whole .next, or clean before building.
Terminal
# cache key for .next/cache only; rebuild .next fresh each run
rm -rf .next && npm run build

Make the build reproducible before you debug it

  • Pin the Node major in setup-node and in engines. A bundler that resolves native bindings will pick a different prebuilt binary across majors.
  • Delete node_modules locally and reinstall from the lockfile before concluding the runner is at fault; most "works locally" reports are stale local state.
  • Set CI=true locally to reproduce. Several toolchains change behaviour under it, including treating warnings as errors.
  • Exit code 137 is an out-of-memory kill. Raise --max-old-space-size or move to a larger runner rather than searching the bundler config.

How to prevent it

  • Fail the pipeline if next build does not exit zero before downstream steps.
  • Cache .next/cache only, never the full .next artifact.

Frequently asked questions

What causes Next.js ENOENT .next/build-manifest?
There are 2 common causes: build step skipped or failed silently and partial .next cache restored. next start/export ran without a successful next build first, so .next is missing or incomplete.
How do I fix Next.js ENOENT .next/build-manifest?
There are 2 fixes depending on which cause you have: build before start/export and stop caching the full .next output. Work through them in order, since the first is the most common.
What does Next.js ENOENT .next/build-manifest actually mean?
A next start, export, or post-build step fails with ENOENT: no such file or directory, open '.next/build-manifest.json'.
How do I stop Next.js ENOENT .next/build-manifest happening again?
Fail the pipeline if next build does not exit zero before downstream steps. The prevention section lists 2 changes that keep it from recurring.

Related guides

References

Not every red build is your code. Latchkey repairs the ones that are not, on the runner. Start free → 30-day trial · No credit card