anomalyco/sst · error · VisibleError

No package.json found at "${sitePath}".

Error message

No package.json found at "${sitePath}".

What it means

In base-ssr-site's resolveBuildCommand, when no explicit build command is provided, SST requires the site directory to contain a package.json (to read its build script). This error is thrown when fs.existsSync finds no package.json at sitePath, meaning the directory is not a Node-based app SST can build.

Source

Thrown at platform/src/components/base/base-ssr-site.ts:45

  return all([
    sitePath,
    buildCommand ?? args.buildCommand,
    args.link,
    args.environment,
    buildEnvironment,
  ]).apply(
    ([sitePath, userCommand, links, environment, extraBuildEnvironment]) => {
      const cmd = resolveBuildCommand();
      const result = runBuild();
      return result.id.apply(() => sitePath);

      function resolveBuildCommand() {
        if (userCommand) return userCommand;

        // Ensure that the site has a build script defined
        if (!userCommand) {
          if (!fs.existsSync(path.join(sitePath, "package.json"))) {
            throw new VisibleError(`No package.json found at "${sitePath}".`);
          }
          const packageJson = JSON.parse(
            fs.readFileSync(path.join(sitePath, "package.json")).toString(),
          );
          if (!packageJson.scripts || !packageJson.scripts.build) {
            throw new VisibleError(
              `No "build" script found within package.json in "${sitePath}".`,
            );
          }
        }

        if (
          fs.existsSync(path.join(sitePath, "yarn.lock")) ||
          fs.existsSync(path.join($cli.paths.root, "yarn.lock"))
        )
          return "yarn run build";
        if (
          fs.existsSync(path.join(sitePath, "pnpm-lock.yaml")) ||

View on GitHub (pinned to a0bd20f762)

Solutions

  1. Fix the `path` argument to point at the directory containing package.json.
  2. Add a package.json with a build script if the directory genuinely is a Node app.
  3. Use a static site component (sst.aws.Bucket with a static site, e.g. StaticSite) for non-Node sites instead.
  4. Ensure the build command or script is supplied if the project structure is unusual.

Example fix

// before
new sst.aws.Nextjs("Web", { path: "./web/dist" });
// after
new sst.aws.Nextjs("Web", { path: "./web" });
Defensive patterns

Strategy: validation

Validate before calling

import fs from "node:fs";
const sitePath = "./web";
if (!fs.existsSync(`${sitePath}/package.json`))
  throw new Error(`Add package.json to ${sitePath} or fix the site component's path arg.`);

Prevention

When it happens

Trigger: Creating an sst.aws Nextjs/Astro/Remix/etc. (SSR) site with `path` pointing to a directory without package.json, or a typo'd path, or a non-Node static site used with an SSR component.

Common situations: Wrong relative path from the sst.config.ts location; pointing at the build output directory instead of the source; a plain HTML site mistakenly using an SSR site component.

Related errors


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