vercel/next.js · critical

Could not find a production build in the '${this.distDir}' d

Error message

Could not find a production build in the '${this.distDir}' directory. Try building your app with 'next build' before starting the production server. https://nextjs.org/docs/messages/production-start-no-build-id

What it means

Thrown by NextNodeServer.getBuildId() when the BUILD_ID file (this.distDir/BUILD_ID) cannot be read with an ENOENT (file-not-found) error. The production server reads BUILD_ID to identify which build it is serving; its absence means no build output exists in the configured distDir.

Source

Thrown at packages/next/src/server/next-server.ts:524

      pathname,
      this.distDir,
      this.nextConfig.i18n?.locales,
      this.enabledDirectories.app
    )
  }

  protected getBuildId(): string {
    const buildIdFile = join(
      /* turbopackIgnore: true */ this.distDir,
      BUILD_ID_FILE
    )
    try {
      return fs
        .readFileSync(/* turbopackIgnore: true */ buildIdFile, 'utf8')
        .trim()
    } catch (err: any) {
      if (err.code === 'ENOENT') {
        throw new Error(
          `Could not find a production build in the '${this.distDir}' directory. Try building your app with 'next build' before starting the production server. https://nextjs.org/docs/messages/production-start-no-build-id`
        )
      }

      throw err
    }
  }

  protected getEnabledDirectories(dev: boolean): NextEnabledDirectories {
    const dir = dev ? this.dir : this.serverDistDir

    return {
      app: findDir(dir, 'app') ? true : false,
      pages: findDir(dir, 'pages') ? true : false,
    }
  }

  protected sendRenderResult(

View on GitHub (pinned to 0ae8c72462)

Solutions

  1. Run `next build` before `next start` so that <distDir>/BUILD_ID is generated.
  2. Verify `distDir` in next.config.js matches the directory the server is reading (default is `.next`).
  3. Confirm the build output directory is present in your deployment artifact (Docker image, server bundle) before starting the server.
  4. If using a custom server, ensure the `dir`/`distDir` passed to NextServer points at the built output.

Example fix

// before
# only ran: next start
// after
# build first, then start
next build && next start
Defensive patterns

Strategy: validation

Validate before calling

const fs = require('fs')
const path = require('path')
const distDir = '.next' // match next.config distDir
if (!fs.existsSync(path.join(distDir, 'BUILD_ID'))) {
  throw new Error(`No build in ${distDir}. Run 'next build' first.`)
}

Prevention

When it happens

Trigger: Running `next start` (or a production server) without ever running `next build`; setting a custom `distDir` in next.config.js so the server looks in a different directory than where the build wrote; deleting/clearing the .next directory after building; deploying only source without the built artifacts.

Common situations: CI/CD pipeline runs `next start` but skipped the build step; Docker image copies source but not the built .next folder; distDir was renamed in config but the server is pointed at the default .next; a fresh checkout where someone ran start instead of dev.

Related errors


AI-assisted analysis of vercel/next.js@0ae8c72462 (2026-08-06). Data as JSON: /api/errors/c9816a3d4cb01480. Report an issue: GitHub.