sveltejs/kit · error · Error
Failed to locate provided tsconfig or jsconfig
Error message
Failed to locate provided tsconfig or jsconfig
What it means
When the tsconfig path is explicitly provided (via options), `load_tsconfig` walks up from the filename looking for tsconfig.json/jsconfig.json and throws this error if the explicitly provided location contains no such config file.
Source
Thrown at packages/package/src/typescript.js:250
}
let config_filename;
/** @type {string[]} */
const traversed_dirs = [];
if (tsconfig) {
if (fs.existsSync(tsconfig)) {
config_filename = tsconfig;
const cached = cache.get(config_filename);
if (cached) {
return cached;
} else {
// This isn't really a dir, but it simplifies the caching logic
traversed_dirs.push(config_filename);
}
} else {
throw new Error('Failed to locate provided tsconfig or jsconfig');
}
} else {
// ts.findConfigFile is broken (it will favour a distant tsconfig
// over a near jsconfig, and then only when you call it twice)
// so we implement it ourselves
let dir = filename;
while (dir !== (dir = path.dirname(dir))) {
const cached = cache.get(dir);
if (cached) {
for (const traversed of traversed_dirs) {
cache.set(traversed, cached);
}
return cached;
}
traversed_dirs.push(dir);
const tsconfig = path.join(dir, 'tsconfig.json');View on GitHub (pinned to 03f1687fe6)
Solutions
- Fix the provided path so it points at the directory (or file) containing tsconfig.json/jsconfig.json.
- Verify the file exists at the given path: `ls <path>/tsconfig.json`.
- Omit the tsconfig option to let the packager auto-discover it from the project root.
Example fix
// before svelte-package --tsconfig ./configs // after svelte-package --tsconfig ./configs/tsconfig.json
Defensive patterns
Strategy: validation
Validate before calling
import fs from 'node:fs';
const p = './configs';
if (!fs.existsSync(`${p}/tsconfig.json`) && !fs.existsSync(`${p}/jsconfig.json`)) {
throw new Error(`no tsconfig/jsconfig at ${p}`);
} Try / catch
try {
await run(['svelte-package', '--tsconfig', './configs']);
} catch (e) {
if (String(e.message).includes('Failed to locate provided tsconfig')) {
throw new Error('Point --tsconfig at the directory containing tsconfig.json');
}
throw e;
} Prevention
- Point --tsconfig at the exact directory or file holding the config
- Update packaging flags when config files move
- Prefer auto-discovery (omit the flag) when the config sits at the project root
When it happens
Trigger: Passing a `tsconfig` option/flag to svelte-package pointing at a directory or file where no tsconfig.json or jsconfig.json actually exists.
Common situations: Typo in the `--tsconfig` flag value; pointing at the tsconfig's output directory rather than its location; config moved/renamed but packaging options not updated.
Related errors
- Failed to locate tsconfig or jsconfig
- Malformed tsconfig ${JSON.stringify(error, null, 2)}
- Invalid alias key: ${key}
- Invalid alias value: ${value}
- ${path.relative('.', input)} does not exist
AI-assisted analysis of sveltejs/kit@03f1687fe6 (2026-09-02).
Data as JSON: /api/errors/d790c95063f195cd.
Report an issue: GitHub.