{"record":{"id":"91ecb3fda149f1aa","repo":"anomalyco/sst","slug":"no-build-script-found-within-package-json-in","errorCode":null,"errorMessage":"No \"build\" script found within package.json in \"${sitePath}\".","messagePattern":"No \"build\" script found within package\\.json in \"(.+?)\"\\.","errorType":"validation","errorClass":"VisibleError","httpStatus":null,"severity":"error","filePath":"platform/src/components/base/base-ssr-site.ts","lineNumber":51,"sourceCode":"  ]).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\")) ||\n          fs.existsSync(path.join($cli.paths.root, \"pnpm-lock.yaml\"))\n        )\n          return \"pnpm run build\";\n        if (\n          fs.existsSync(path.join(sitePath, \"bun.lockb\")) ||\n          fs.existsSync(path.join($cli.paths.root, \"bun.lockb\")) ||","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/anomalyco/sst/blob/a0bd20f762883e72a35caccb4896c42ce5b3f707/platform/src/components/base/base-ssr-site.ts#L33-L69","documentation":"After loading package.json, resolveBuildCommand checks for a scripts.build entry and throws this error when the package.json exists but has no build script (or no scripts at all). SST builds SSR sites with `npm run build` (or the package manager equivalent) by default, so a build script is required.","triggerScenarios":"Site's package.json lacks `scripts.build` — e.g. only has dev/start scripts, or an empty scripts object — while deploying an SSR site without a custom `build` command in args.","commonSituations":"Frameworks or boilerplates without a standard build script; monorepo packages whose build lives in a parent workspace; freshly scaffolded projects that never defined build.","solutions":["Add a \"build\" script to the site's package.json.","Or pass an explicit `build` command in the site component args to bypass the default script lookup.","Verify you're pointing at the right package (in monorepos) that actually has the build script."],"exampleFix":"// before: package.json\n{ \"name\": \"web\", \"scripts\": { \"dev\": \"vite\" } }\n// after\n{ \"name\": \"web\", \"scripts\": { \"dev\": \"vite\", \"build\": \"vite build\" } }","handlingStrategy":"validation","validationCode":"const pkg = JSON.parse(fs.readFileSync(`${sitePath}/package.json`, \"utf8\"));\nif (!pkg.scripts?.build)\n  throw new Error(`Add a \"build\" script to ${sitePath}/package.json or pass build.command in the site args.`);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure every SSR site package defines a standard build script","Pass an explicit build command in args when scripts are nonstandard","In monorepos, verify the package.json being read is the site's own"],"tags":["ssr","site-build","package-json","config-validation"],"backgroundTag":"missing-build-script","analyzedSha":"a0bd20f762883e72a35caccb4896c42ce5b3f707","analyzedAt":"2026-08-30T11:26:00.383Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}