anomalyco/sst · error · VisibleError
TanStack Start server bundle not found at: "${serverPath}"
Error message
TanStack Start server bundle not found at:
"${serverPath}". What it means
Having parsed `dist/server/wrangler.json`, SST resolves the server entry (`main`, e.g. `index.js`) relative to `dist/server`. If that file does not exist on disk, the build output is incomplete or inconsistent with wrangler.json, and SST throws.
Source
Thrown at platform/src/components/cloudflare/tan-stack-start.ts:322
directory?: string;
};
};
if (!wrangler.main) {
throw new VisibleError(
`TanStack Start build output at "${path.resolve(wranglerPath)}" is missing the Worker entry in \`main\`.`,
);
}
const serverPath = path.resolve(outputPath, "dist", "server", wrangler.main);
const assetsPath = path.resolve(
outputPath,
"dist",
"server",
wrangler.assets?.directory ?? "../client",
);
if (!(await existsAsync(serverPath))) {
throw new VisibleError(
`TanStack Start server bundle not found at:\n "${serverPath}".`,
);
}
if (!(await existsAsync(assetsPath))) {
throw new VisibleError(
`TanStack Start assets directory not found at:\n "${assetsPath}".`,
);
}
return {
server: toPlanPath(serverPath),
assets: toPlanPath(assetsPath),
};
}
for (const serverFile of ["index.js", "index.mjs"]) {
const serverPath = path.join(
outputPath,View on GitHub (pinned to a0bd20f762)
Solutions
- Delete `dist/` and run a full clean build with the Cloudflare adapter
- Confirm the file referenced by wrangler `main` exists under `dist/server` before deploying
- Stop committing build output; build fresh in CI
Example fix
// before: dist/server/wrangler.json says main: index.js but only index-abc123.js exists rm -rf dist // after: rebuild so main and emitted file match, then sst deploy
Defensive patterns
Strategy: validation
Validate before calling
import { readFileSync, existsSync } from 'fs';
const w = JSON.parse(readFileSync('apps/web/dist/server/wrangler.json', 'utf8'));
if (!existsSync(`apps/web/dist/server/${w.main}`))
throw new Error(`Server bundle missing: dist/server/${w.main}; clean dist and rebuild`); Try / catch
try {
await deploy();
} catch (e) {
if (/server bundle not found/.test(e.message)) console.error('Stale or partial dist output; rebuild from clean');
} Prevention
- Clean dist after adapter/config changes
- Never mix old build output with new config
- Verify wrangler main file exists before deploy
- Build fresh in CI instead of caching dist
When it happens
Trigger: `dist/server/wrangler.json` lists a `main` whose file isn't present: stale wrangler.json from an old build, interrupted build, or the adapter writing a main path that the build didn't emit.
Common situations: Deploying after a partially failed build; mixing old dist output with new config; committing dist to git so stale wrangler.json points at removed files.
Related errors
- TanStack Start build output not found in "${path.resolve(out
- TanStack Start build output at "${path.resolve(wranglerPath)
- TanStack Start assets directory not found at: "${assetsPat
- TanStack Start assets directory not found at: "${path.reso
- Could not load OpenNext output file at "${openNextOutputPath
AI-assisted analysis of anomalyco/sst@a0bd20f762 (2026-08-30).
Data as JSON: /api/errors/d8707df84338b834.
Report an issue: GitHub.