{"record":{"id":"c9816a3d4cb01480","repo":"vercel/next.js","slug":"could-not-find-a-production-build-in-the-this-d","errorCode":null,"errorMessage":"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","messagePattern":"Could not find a production build in the '(.+?)' directory\\. Try building your app with 'next build' before starting the production server\\. https://nextjs\\.org/docs/messages/production-start-no-build-id","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"packages/next/src/server/next-server.ts","lineNumber":524,"sourceCode":"      pathname,\n      this.distDir,\n      this.nextConfig.i18n?.locales,\n      this.enabledDirectories.app\n    )\n  }\n\n  protected getBuildId(): string {\n    const buildIdFile = join(\n      /* turbopackIgnore: true */ this.distDir,\n      BUILD_ID_FILE\n    )\n    try {\n      return fs\n        .readFileSync(/* turbopackIgnore: true */ buildIdFile, 'utf8')\n        .trim()\n    } catch (err: any) {\n      if (err.code === 'ENOENT') {\n        throw new Error(\n          `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`\n        )\n      }\n\n      throw err\n    }\n  }\n\n  protected getEnabledDirectories(dev: boolean): NextEnabledDirectories {\n    const dir = dev ? this.dir : this.serverDistDir\n\n    return {\n      app: findDir(dir, 'app') ? true : false,\n      pages: findDir(dir, 'pages') ? true : false,\n    }\n  }\n\n  protected sendRenderResult(","sourceCodeStart":506,"sourceCodeEnd":542,"githubUrl":"https://github.com/vercel/next.js/blob/0ae8c72462952df163f1b1e0726641bc5b40dc93/packages/next/src/server/next-server.ts#L506-L542","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Run `next build` before `next start` so that <distDir>/BUILD_ID is generated.","Verify `distDir` in next.config.js matches the directory the server is reading (default is `.next`).","Confirm the build output directory is present in your deployment artifact (Docker image, server bundle) before starting the server.","If using a custom server, ensure the `dir`/`distDir` passed to NextServer points at the built output."],"exampleFix":"// before\n# only ran: next start\n// after\n# build first, then start\nnext build && next start","handlingStrategy":"validation","validationCode":"const fs = require('fs')\nconst path = require('path')\nconst distDir = '.next' // match next.config distDir\nif (!fs.existsSync(path.join(distDir, 'BUILD_ID'))) {\n  throw new Error(`No build in ${distDir}. Run 'next build' first.`)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always run `next build` before `next start`; chain them in your start script.","Verify the BUILD_ID file exists in your Docker image/deployment artifact before starting.","Keep distDir consistent between build and start (don't change next.config.js between them).","In CI, fail fast if the build step didn't produce BUILD_ID."],"tags":["build","production","dist-dir","startup","deployment"],"analyzedSha":"0ae8c72462952df163f1b1e0726641bc5b40dc93","analyzedAt":"2026-08-06T19:44:29.143Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}