withastro/astro · error · Error
Specified tsconfig file `${tsconfig}` does not exist.
Error message
Specified tsconfig file `${tsconfig}` does not exist. What it means
Thrown by the Astro language server's `getTsconfig()` when a tsconfig path was explicitly specified (`tsconfigPath` option) but the resolved file does not exist on disk. The checker refuses to proceed with a missing config because type resolution would be unreliable.
Source
Thrown at packages/language-tools/language-server/src/check.ts:222
* `Cannot read properties of undefined` error. Fail early with an actionable message.
*/
private assertCompatibleTypeScript() {
if (typeof this.ts.findConfigFile !== 'function' || this.ts.sys === undefined) {
const version = this.ts.version ? ` (found ${this.ts.version})` : '';
throw new Error(
`The TypeScript module loaded${version} does not expose the programmatic API that \`astro check\` relies on. ` +
`TypeScript's native compiler (7.0 and later) does not ship this API yet. ` +
`Until it does, run \`astro check\` with a TypeScript version that still provides it (6.x). ` +
`See https://github.com/withastro/roadmap/discussions/1321 to track support.`,
);
}
}
private getTsconfig() {
if (this.tsconfigPath) {
const tsconfig = resolve(this.workspacePath, this.tsconfigPath.replace(/^~/, homedir()));
if (!existsSync(tsconfig)) {
throw new Error(`Specified tsconfig file \`${tsconfig}\` does not exist.`);
}
return tsconfig;
}
const searchPath = this.workspacePath;
const tsconfig =
this.ts.findConfigFile(searchPath, this.ts.sys.fileExists) ||
this.ts.findConfigFile(searchPath, this.ts.sys.fileExists, 'jsconfig.json');
return tsconfig;
}
}
View on GitHub (pinned to d081033d5f)
Solutions
- Verify the file exists at the resolved path printed in the error.
- Omit the explicit `tsconfigPath` to let the language server auto-discover `tsconfig.json`/`jsconfig.json`.
- Fix the path or recreate the missing tsconfig file.
Example fix
// before: tsconfigPath points at a non-existent file
check({ tsconfigPath: '~/tsconfig.build.json' })
// after: use the workspace tsconfig.json (auto-discovered)
check({}) Defensive patterns
Strategy: validation
Validate before calling
import { existsSync } from 'node:fs';
if (tsconfigPath && !existsSync(resolve(workspacePath, tsconfigPath.replace(/^~/, homedir())))) {
throw new Error(`tsconfig not found at ${tsconfigPath}; falling back to auto-discovery.`);
} Prevention
- Omit `tsconfigPath` to use auto-discovery unless you need a specific file.
- Re-check the path after moving tsconfig files.
- Validate path existence before passing to the checker.
When it happens
Trigger: Passing `tsconfig: '~/tsconfig.custom.json'` (or any path) where no file exists. The `~` expands to the home directory; a relative path resolves against `workspacePath`. Deleting/renaming a tsconfig after referencing it.
Common situations: Pointing `tsconfig` at a path from an old project layout. A monorepo where the tsconfig moved. A typo in the configured path.
Related errors
- Integration ${integrationName} is injecting a type that does
- The TypeScript module loaded${version} does not expose the p
- The `typescript.tsdk` init option is required. It should poi
- CONTENT_TOO_LARGE
- Configured image service is not a local service
AI-assisted analysis of withastro/astro@d081033d5f (2026-08-12).
Data as JSON: /api/errors/7df95e6a26f9771f.
Report an issue: GitHub.