{"record":{"id":"974300669a97f786","repo":"anomalyco/sst","slug":"build-id-not-found-in-next-build-id-for-site","errorCode":null,"errorMessage":"Build ID not found in \".next/BUILD_ID\" for site \"${name}\". Ensure your Next.js app was built successfully.","messagePattern":"Build ID not found in \"\\.next/BUILD_ID\" for site \"(.+?)\"\\. Ensure your Next\\.js app was built successfully\\.","errorType":"exception","errorClass":"VisibleError","httpStatus":null,"severity":"error","filePath":"platform/src/components/aws/nextjs.ts","lineNumber":818,"sourceCode":"              bundle: \".open-next/dynamodb-provider\",\n            };\n          }\n          return {\n            openNextOutput: json,\n            base: loadBasePath(),\n            buildId: loadBuildId(),\n            prerenderManifest: loadPrerenderManifest(),\n          };\n        }\n\n        function loadBuildId() {\n          try {\n            return fs\n              .readFileSync(path.join(outputPath, \".next/BUILD_ID\"))\n              .toString();\n          } catch (e) {\n            console.error(e);\n            throw new VisibleError(\n              `Build ID not found in \".next/BUILD_ID\" for site \"${name}\". Ensure your Next.js app was built successfully.`,\n            );\n          }\n        }\n\n        function loadBasePath() {\n          try {\n            const content = fs.readFileSync(\n              path.join(outputPath, \".next\", \"routes-manifest.json\"),\n              \"utf-8\",\n            );\n            const json = JSON.parse(content) as {\n              basePath: string;\n            };\n            return json.basePath === \"\" ? undefined : json.basePath;\n          } catch (e) {\n            console.error(e);\n            throw new VisibleError(","sourceCodeStart":800,"sourceCodeEnd":836,"githubUrl":"https://github.com/anomalyco/sst/blob/a0bd20f762883e72a35caccb4896c42ce5b3f707/platform/src/components/aws/nextjs.ts#L800-L836","documentation":"SST reads the Next.js app's .next/BUILD_ID file to identify the build. If that file cannot be read (missing because the app was never built with `next build`, or a build failed), SST logs the underlying fs error and throws this VisibleError naming the site.","triggerScenarios":"Deploying a Nextjs component whose output directory contains no .next/BUILD_ID — e.g. `next build` was skipped, failed partway, or the output path is misconfigured.","commonSituations":"CI pipelines where the Next.js build step silently failed; running deploy from a fresh clone without building; wrong `path` pointing at a non-Next.js directory; stale node_modules or interrupted builds.","solutions":["Run `next build` (or the full `opennextjs build`) in the app directory and confirm .next/BUILD_ID exists","Fix the underlying build error shown in the console.error output above this message","Verify the Nextjs component's `path` points to the actual Next.js app root","Clear .next and node_modules and rebuild if the build output is stale or corrupted"],"exampleFix":"// before\n// deploy without building\nsst deploy\n// after\ncd apps/web && npm run build && ls .next/BUILD_ID\nsst deploy","handlingStrategy":"validation","validationCode":"const p = path.join(appPath, \".next\", \"BUILD_ID\");\nif (!fs.existsSync(p)) throw new Error(`Missing ${p}; run next build first`);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run `next build` (via opennextjs build) before deploying","Fail CI fast if the Next.js build errors instead of continuing to deploy","Confirm the component `path` resolves to the Next.js app directory","Clear .next and rebuild when output looks stale or truncated"],"tags":["nextjs","build-id","missing-file","build"],"backgroundTag":"missing-build-output","analyzedSha":"a0bd20f762883e72a35caccb4896c42ce5b3f707","analyzedAt":"2026-08-30T11:26:00.383Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}