{"record":{"id":"34a95ecbbfdbdd1e","repo":"anomalyco/sst","slug":"base-path-configuration-not-found-in-next-routes","errorCode":null,"errorMessage":"Base path configuration not found in \".next/routes-manifest.json\" for site \"${name}\". Check your Next.js configuration.","messagePattern":"Base path configuration not found in \"\\.next/routes-manifest\\.json\" for site \"(.+?)\"\\. Check your Next\\.js configuration\\.","errorType":"exception","errorClass":"VisibleError","httpStatus":null,"severity":"error","filePath":"platform/src/components/aws/nextjs.ts","lineNumber":836,"sourceCode":"            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(\n              `Base path configuration not found in \".next/routes-manifest.json\" for site \"${name}\". Check your Next.js configuration.`,\n            );\n          }\n        }\n\n        function loadPrerenderManifest() {\n          try {\n            const content = fs\n              .readFileSync(\n                path.join(outputPath, \".next/prerender-manifest.json\"),\n              )\n              .toString();\n            return JSON.parse(content) as {\n              version: number;\n              routes: Record<string, unknown>;\n            };\n          } catch (e) {\n            console.debug(\"Failed to load prerender-manifest.json\", e);","sourceCodeStart":818,"sourceCodeEnd":854,"githubUrl":"https://github.com/anomalyco/sst/blob/a0bd20f762883e72a35caccb4896c42ce5b3f707/platform/src/components/aws/nextjs.ts#L818-L854","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nnew sst.aws.Nextjs(\"Web\", { path: \"packages/web\" }); // deployed without building\n// after\n// package.json: \"deploy\": \"next build && sst deploy\"\nnew sst.aws.Nextjs(\"Web\", { path: \"packages/web\" });","handlingStrategy":"validation","validationCode":"import { existsSync, readFileSync } from \"fs\";\nconst manifest = \".next/routes-manifest.json\";\nif (!existsSync(manifest)) throw new Error(\"Run `next build` before deploying: routes-manifest.json missing\");\nconst parsed = JSON.parse(readFileSync(manifest, \"utf8\"));\nif (typeof parsed.basePath !== \"string\") throw new Error(\"routes-manifest.json is missing a valid basePath\");","typeGuard":"function hasValidRoutesManifest(m: unknown): m is { basePath: string } {\n  return typeof m === \"object\" && m !== null && typeof (m as any).basePath === \"string\";\n}","tryCatchPattern":"try {\n  const manifest = JSON.parse(readFileSync(\".next/routes-manifest.json\", \"utf8\"));\n} catch {\n  throw new Error(\".next build output invalid — run `next build` first\");\n}","preventionTips":["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"],"tags":["nextjs","build-output","deployment","missing-file"],"backgroundTag":"missing-build-artifact","analyzedSha":"a0bd20f762883e72a35caccb4896c42ce5b3f707","analyzedAt":"2026-08-30T11:26:00.383Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}