{"record":{"id":"2eeb553fcd20c91e","repo":"anomalyco/sst","slug":"no-package-json-found-at-sitepath","errorCode":null,"errorMessage":"No package.json found at \"${sitePath}\".","messagePattern":"No package\\.json found at \"(.+?)\"\\.","errorType":"validation","errorClass":"VisibleError","httpStatus":null,"severity":"error","filePath":"platform/src/components/base/base-ssr-site.ts","lineNumber":45,"sourceCode":"  return all([\n    sitePath,\n    buildCommand ?? args.buildCommand,\n    args.link,\n    args.environment,\n    buildEnvironment,\n  ]).apply(\n    ([sitePath, userCommand, links, environment, extraBuildEnvironment]) => {\n      const cmd = resolveBuildCommand();\n      const result = runBuild();\n      return result.id.apply(() => sitePath);\n\n      function resolveBuildCommand() {\n        if (userCommand) return userCommand;\n\n        // Ensure that the site has a build script defined\n        if (!userCommand) {\n          if (!fs.existsSync(path.join(sitePath, \"package.json\"))) {\n            throw new VisibleError(`No package.json found at \"${sitePath}\".`);\n          }\n          const packageJson = JSON.parse(\n            fs.readFileSync(path.join(sitePath, \"package.json\")).toString(),\n          );\n          if (!packageJson.scripts || !packageJson.scripts.build) {\n            throw new VisibleError(\n              `No \"build\" script found within package.json in \"${sitePath}\".`,\n            );\n          }\n        }\n\n        if (\n          fs.existsSync(path.join(sitePath, \"yarn.lock\")) ||\n          fs.existsSync(path.join($cli.paths.root, \"yarn.lock\"))\n        )\n          return \"yarn run build\";\n        if (\n          fs.existsSync(path.join(sitePath, \"pnpm-lock.yaml\")) ||","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/anomalyco/sst/blob/a0bd20f762883e72a35caccb4896c42ce5b3f707/platform/src/components/base/base-ssr-site.ts#L27-L63","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Fix the `path` argument to point at the directory containing package.json.","Add a package.json with a build script if the directory genuinely is a Node app.","Use a static site component (sst.aws.Bucket with a static site, e.g. StaticSite) for non-Node sites instead.","Ensure the build command or script is supplied if the project structure is unusual."],"exampleFix":"// before\nnew sst.aws.Nextjs(\"Web\", { path: \"./web/dist\" });\n// after\nnew sst.aws.Nextjs(\"Web\", { path: \"./web\" });","handlingStrategy":"validation","validationCode":"import fs from \"node:fs\";\nconst sitePath = \"./web\";\nif (!fs.existsSync(`${sitePath}/package.json`))\n  throw new Error(`Add package.json to ${sitePath} or fix the site component's path arg.`);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run sst from the repo root and use paths relative to sst.config.ts","Don't point SSR components at build output directories","Use StaticSite-style components for non-Node sites"],"tags":["ssr","site-build","package-json","config-validation"],"backgroundTag":"missing-package-json","analyzedSha":"a0bd20f762883e72a35caccb4896c42ce5b3f707","analyzedAt":"2026-08-30T11:26:00.383Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}