anomalyco/sst · error · VisibleError

Build ID not found in ".next/BUILD_ID" for site "${name}". E

Error message

Build ID not found in ".next/BUILD_ID" for site "${name}". Ensure your Next.js app was built successfully.

What it means

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.

Source

Thrown at platform/src/components/aws/nextjs.ts:818

              bundle: ".open-next/dynamodb-provider",
            };
          }
          return {
            openNextOutput: json,
            base: loadBasePath(),
            buildId: loadBuildId(),
            prerenderManifest: loadPrerenderManifest(),
          };
        }

        function loadBuildId() {
          try {
            return fs
              .readFileSync(path.join(outputPath, ".next/BUILD_ID"))
              .toString();
          } catch (e) {
            console.error(e);
            throw new VisibleError(
              `Build ID not found in ".next/BUILD_ID" for site "${name}". Ensure your Next.js app was built successfully.`,
            );
          }
        }

        function loadBasePath() {
          try {
            const content = fs.readFileSync(
              path.join(outputPath, ".next", "routes-manifest.json"),
              "utf-8",
            );
            const json = JSON.parse(content) as {
              basePath: string;
            };
            return json.basePath === "" ? undefined : json.basePath;
          } catch (e) {
            console.error(e);
            throw new VisibleError(

View on GitHub (pinned to a0bd20f762)

Solutions

  1. Run `next build` (or the full `opennextjs build`) in the app directory and confirm .next/BUILD_ID exists
  2. Fix the underlying build error shown in the console.error output above this message
  3. Verify the Nextjs component's `path` points to the actual Next.js app root
  4. Clear .next and node_modules and rebuild if the build output is stale or corrupted

Example fix

// before
// deploy without building
sst deploy
// after
cd apps/web && npm run build && ls .next/BUILD_ID
sst deploy
Defensive patterns

Strategy: validation

Validate before calling

const p = path.join(appPath, ".next", "BUILD_ID");
if (!fs.existsSync(p)) throw new Error(`Missing ${p}; run next build first`);

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of anomalyco/sst@a0bd20f762 (2026-08-30). Data as JSON: /api/errors/974300669a97f786. Report an issue: GitHub.