anomalyco/sst · error · Error
Could not find a ${target} file
Error message
Could not find a ${target} file What it means
findBelow searches a directory and (skipping node_modules and .sst) all its subdirectories for a given target file name (e.g. 'sst.config.ts' or 'package.json') and returns the containing directory. This error is thrown when the search completes and no file with that name exists anywhere below the starting directory.
Source
Thrown at platform/src/util/fs.ts:33
async function loop(dir: string): Promise<string | undefined> {
const current = path.join(dir, target);
if (await existsAsync(current)) return dir;
const files = await fs.readdir(dir, { withFileTypes: true });
for (const file of files) {
if (file.name === "node_modules") continue;
if (file.name === ".sst") continue;
if (file.isDirectory()) {
const full = path.join(dir, file.name);
const result = await loop(full);
if (result) return result;
}
}
return;
}
const value = await loop(dir);
if (!value) throw new Error(`Could not find a ${target} file`);
return value;
}
export function isChild(parent: string, child: string) {
const relative = path.relative(parent, child);
return Boolean(
relative && !relative.startsWith("..") && !path.isAbsolute(relative),
);
}
export async function existsAsync(input: string) {
return fs
.access(input)
.then(() => true)
.catch(() => false);
}
View on GitHub (pinned to a0bd20f762)
Solutions
- cd into the directory containing the target file (or a subdirectory of it) before running the command.
- Verify the file exists: ls the project for sst.config.ts and create it if missing (sst init can scaffold it).
- Check the exact file name and casing matches what the CLI expects (case-sensitive on Linux).
- If the config is gitignored, remove that ignore rule and commit the file so other checkouts have it.
Example fix
// before $ cd ~/projects/app/frontend && sst deploy # no sst.config.ts below frontend/ // after $ cd ~/projects/app && sst deploy # sst.config.ts lives here
Defensive patterns
Strategy: try-catch
Validate before calling
import fs from "fs/promises";
const exists = await fs.access(path.join(process.cwd(), "sst.config.ts")).then(() => true, () => false);
if (!exists) console.error("Run this command from an SST app directory containing sst.config.ts"); Type guard
async function hasTarget(dir: string, target: string): Promise<boolean> {
try { await fs.access(path.join(dir, target)); return true; } catch { return false; }
} Try / catch
try {
const dir = await findBelow(process.cwd(), "sst.config.ts");
} catch (e) {
if ((e as Error).message.startsWith("Could not find a")) {
console.error(`No target found below cwd — run from your SST app root`);
process.exit(1);
}
throw e;
} Prevention
- Always run sst commands from the project root where sst.config.ts lives.
- Verify the config file exists and is committed (not gitignored) before invoking the CLI.
- Watch for filename casing differences across OSes (sst.config.ts vs Sst.config.ts).
- Script wrappers can pre-check for the file and print a friendly message before calling sst.
When it happens
Trigger: Running an sst command from a directory tree that does not contain the target file — e.g. invoking the CLI outside an SST app so no sst.config.ts exists below the working directory, or the file was deleted/renamed (e.g. 'sst.config.ts' vs 'Sst.config.ts' case mismatch).
Common situations: Running `sst deploy`/`sst dev` in the repo root when the config lives in a subdirectory and sst was invoked outside it; a missing or renamed sst.config.ts; working from a freshly cloned repo without the config checked in; .gitignore excluding the config file.
Related errors
- File '%s' not found
- Build metadata file not found at "${filePath}". Update your
- Invalid function definition for the "${name}" Function
- Invalid function definition for the "${name}" Function
- Proxy is not enabled. Enable it with "proxy: true".
AI-assisted analysis of anomalyco/sst@a0bd20f762 (2026-08-30).
Data as JSON: /api/errors/b35305632ae9da3b.
Report an issue: GitHub.