anomalyco/sst · error · VisibleError
Base path configuration not found in ".next/routes-manifest.
Error message
Base path configuration not found in ".next/routes-manifest.json" for site "${name}". Check your Next.js configuration. What it means
SST's Nextjs component reads the built app's .next/routes-manifest.json to discover the basePath configured in next.config.js so it can wire up routing/CloudFront correctly. If the file can't be parsed or lacks a usable basePath, it assumes the build output is corrupt or produced by a misconfigured Next.js build and throws this VisibleError.
Source
Thrown at platform/src/components/aws/nextjs.ts:836
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(
`Base path configuration not found in ".next/routes-manifest.json" for site "${name}". Check your Next.js configuration.`,
);
}
}
function loadPrerenderManifest() {
try {
const content = fs
.readFileSync(
path.join(outputPath, ".next/prerender-manifest.json"),
)
.toString();
return JSON.parse(content) as {
version: number;
routes: Record<string, unknown>;
};
} catch (e) {
console.debug("Failed to load prerender-manifest.json", e);View on GitHub (pinned to a0bd20f762)
Solutions
- Run `next build` (or `sst build`) so a fresh .next/routes-manifest.json exists before deploying
- Delete the .next directory and rebuild to rule out a corrupt manifest
- Verify the `path` pointing to the Next.js app in the SST component config is the app root that contains .next
- Check next.config.js basePath is a string (empty string is allowed) and the Next.js version is supported by SST
Example fix
// before
new sst.aws.Nextjs("Web", { path: "packages/web" }); // deployed without building
// after
// package.json: "deploy": "next build && sst deploy"
new sst.aws.Nextjs("Web", { path: "packages/web" }); Defensive patterns
Strategy: validation
Validate before calling
import { existsSync, readFileSync } from "fs";
const manifest = ".next/routes-manifest.json";
if (!existsSync(manifest)) throw new Error("Run `next build` before deploying: routes-manifest.json missing");
const parsed = JSON.parse(readFileSync(manifest, "utf8"));
if (typeof parsed.basePath !== "string") throw new Error("routes-manifest.json is missing a valid basePath"); Type guard
function hasValidRoutesManifest(m: unknown): m is { basePath: string } {
return typeof m === "object" && m !== null && typeof (m as any).basePath === "string";
} Try / catch
try {
const manifest = JSON.parse(readFileSync(".next/routes-manifest.json", "utf8"));
} catch {
throw new Error(".next build output invalid — run `next build` first");
} Prevention
- Always run `next build` before `sst deploy` in CI
- Add .next regeneration to your deploy script ("next build && sst deploy")
- Don't clean or cache-prune .next between build and deploy
- Keep Next.js on an SST-supported version
When it happens
Trigger: Running `sst deploy`/`sst dev` for a Nextjs site where .next/routes-manifest.json is missing, malformed JSON, or JSON.parse throws — e.g. the site was never built (`next build` not run), build artifacts were cleaned, or an incompatible Next.js version produced an unexpected manifest format.
Common situations: Deploying before building the app in CI, a stale or partially-cleaned .next directory, monorepo path misconfiguration pointing at the wrong build output, or upgrading Next.js to a version whose routes-manifest.json no longer matches the expected shape.
Related errors
- Could not load OpenNext output file at "${openNextOutputPath
- Build ID not found in ".next/BUILD_ID" for site "${name}". E
- TanStack Start server bundle not found at: "${serverPath}"
- Build metadata file not found at "${filePath}". Update your
- Lambda@Edge runtime is deprecated. Update your OpenNext conf
AI-assisted analysis of anomalyco/sst@a0bd20f762 (2026-08-30).
Data as JSON: /api/errors/34a95ecbbfdbdd1e.
Report an issue: GitHub.