anomalyco/sst · error · VisibleError

Could not load OpenNext output file at "${openNextOutputPath

Error message

Could not load OpenNext output file at "${openNextOutputPath}". Make sure your Next.js app was built correctly with OpenNext.

What it means

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.

Source

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

            buildId,
          }),
        );

        return {
          plan,
          revalidationQueue,
          revalidationTable,
          revalidationFunction,
        };

        function loadBuildOutput() {
          const openNextOutputPath = path.join(
            outputPath,
            ".open-next",
            "open-next.output.json",
          );
          if (!fs.existsSync(openNextOutputPath)) {
            throw new VisibleError(
              `Could not load OpenNext output file at "${openNextOutputPath}". Make sure your Next.js app was built correctly with OpenNext.`,
            );
          }
          const content = fs.readFileSync(openNextOutputPath).toString();
          const json = JSON.parse(content) as OpenNextOutput;
          // Currently open-next.output.json's initializationFunction value
          // is wrong, it is set to ".open-next/initialization-function"
          if (json.additionalProps?.initializationFunction) {
            json.additionalProps.initializationFunction = {
              handler: "index.handler",
              bundle: ".open-next/dynamodb-provider",
            };
          }
          return {
            openNextOutput: json,
            base: loadBasePath(),
            buildId: loadBuildId(),
            prerenderManifest: loadPrerenderManifest(),

View on GitHub (pinned to a0bd20f762)

Solutions

  1. Run `bunx opennextjs build` (or `npx opennextjs build`) in the Next.js app directory before deploying
  2. Verify .open-next/open-next.output.json exists in the app directory
  3. Confirm the `path` argument of the Nextjs component points to the correct app root
  4. Run the component's build step via the `buildCommand` option so OpenNext output is always generated

Example fix

// before
new sst.aws.Nextjs("Web", { path: "packages/web" });
// deploy fails — .open-next missing
// after
cd packages/web && bunx opennextjs build
new sst.aws.Nextjs("Web", { path: "packages/web" });
Defensive patterns

Strategy: validation

Validate before calling

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

Prevention

When it happens

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

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

Related errors


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