{"record":{"id":"040d38bd724443cc","repo":"anomalyco/sst","slug":"could-not-load-opennext-output-file-at-opennext","errorCode":null,"errorMessage":"Could not load OpenNext output file at \"${openNextOutputPath}\". Make sure your Next.js app was built correctly with OpenNext.","messagePattern":"Could not load OpenNext output file at \"(.+?)\"\\. Make sure your Next\\.js app was built correctly with OpenNext\\.","errorType":"exception","errorClass":"VisibleError","httpStatus":null,"severity":"error","filePath":"platform/src/components/aws/nextjs.ts","lineNumber":789,"sourceCode":"            buildId,\n          }),\n        );\n\n        return {\n          plan,\n          revalidationQueue,\n          revalidationTable,\n          revalidationFunction,\n        };\n\n        function loadBuildOutput() {\n          const openNextOutputPath = path.join(\n            outputPath,\n            \".open-next\",\n            \"open-next.output.json\",\n          );\n          if (!fs.existsSync(openNextOutputPath)) {\n            throw new VisibleError(\n              `Could not load OpenNext output file at \"${openNextOutputPath}\". Make sure your Next.js app was built correctly with OpenNext.`,\n            );\n          }\n          const content = fs.readFileSync(openNextOutputPath).toString();\n          const json = JSON.parse(content) as OpenNextOutput;\n          // Currently open-next.output.json's initializationFunction value\n          // is wrong, it is set to \".open-next/initialization-function\"\n          if (json.additionalProps?.initializationFunction) {\n            json.additionalProps.initializationFunction = {\n              handler: \"index.handler\",\n              bundle: \".open-next/dynamodb-provider\",\n            };\n          }\n          return {\n            openNextOutput: json,\n            base: loadBasePath(),\n            buildId: loadBuildId(),\n            prerenderManifest: loadPrerenderManifest(),","sourceCodeStart":771,"sourceCodeEnd":807,"githubUrl":"https://github.com/anomalyco/sst/blob/a0bd20f762883e72a35caccb4896c42ce5b3f707/platform/src/components/aws/nextjs.ts#L771-L807","documentation":"The Nextjs component reads .open-next/open-next.output.json from the build output directory to build its deployment plan. If the file does not exist at the expected path, SST throws this VisibleError because the app was not built correctly with OpenNext.","triggerScenarios":"Running `sst deploy` (or dev) with `path` pointing at a Next.js app that lacks .open-next/open-next.output.json — OpenNext build never ran, failed, or ran into a different directory.","commonSituations":"Deploying before running `opennextjs build`; a custom build command that skips the OpenNext step; pointing the component at the wrong app directory; stale/cleared .open-next folder.","solutions":["Run `bunx opennextjs build` (or `npx opennextjs build`) in the Next.js app directory before deploying","Verify .open-next/open-next.output.json exists in the app directory","Confirm the `path` argument of the Nextjs component points to the correct app root","Run the component's build step via the `buildCommand` option so OpenNext output is always generated"],"exampleFix":"// before\nnew sst.aws.Nextjs(\"Web\", { path: \"packages/web\" });\n// deploy fails — .open-next missing\n// after\ncd packages/web && bunx opennextjs build\nnew sst.aws.Nextjs(\"Web\", { path: \"packages/web\" });","handlingStrategy":"validation","validationCode":"const p = path.join(appPath, \".open-next\", \"open-next.output.json\");\nif (!fs.existsSync(p)) throw new Error(`Missing ${p}; run opennextjs build first`);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always run the OpenNext build before `sst deploy`","Set the component's buildCommand so the OpenNext output is generated automatically","Verify the `path` argument points to the Next.js app root","Add a CI step asserting .open-next/open-next.output.json exists before deploy"],"tags":["nextjs","opennext","build-output","missing-file"],"backgroundTag":"missing-build-output","analyzedSha":"a0bd20f762883e72a35caccb4896c42ce5b3f707","analyzedAt":"2026-08-30T11:26:00.383Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}