{"record":{"id":"d790c95063f195cd","repo":"sveltejs/kit","slug":"failed-to-locate-provided-tsconfig-or-jsconfig","errorCode":null,"errorMessage":"Failed to locate provided tsconfig or jsconfig","messagePattern":"Failed to locate provided tsconfig or jsconfig","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/package/src/typescript.js","lineNumber":250,"sourceCode":"\t}\n\n\tlet config_filename;\n\t/** @type {string[]} */\n\tconst traversed_dirs = [];\n\n\tif (tsconfig) {\n\t\tif (fs.existsSync(tsconfig)) {\n\t\t\tconfig_filename = tsconfig;\n\n\t\t\tconst cached = cache.get(config_filename);\n\t\t\tif (cached) {\n\t\t\t\treturn cached;\n\t\t\t} else {\n\t\t\t\t// This isn't really a dir, but it simplifies the caching logic\n\t\t\t\ttraversed_dirs.push(config_filename);\n\t\t\t}\n\t\t} else {\n\t\t\tthrow new Error('Failed to locate provided tsconfig or jsconfig');\n\t\t}\n\t} else {\n\t\t// ts.findConfigFile is broken (it will favour a distant tsconfig\n\t\t// over a near jsconfig, and then only when you call it twice)\n\t\t// so we implement it ourselves\n\t\tlet dir = filename;\n\t\twhile (dir !== (dir = path.dirname(dir))) {\n\t\t\tconst cached = cache.get(dir);\n\t\t\tif (cached) {\n\t\t\t\tfor (const traversed of traversed_dirs) {\n\t\t\t\t\tcache.set(traversed, cached);\n\t\t\t\t}\n\t\t\t\treturn cached;\n\t\t\t}\n\n\t\t\ttraversed_dirs.push(dir);\n\n\t\t\tconst tsconfig = path.join(dir, 'tsconfig.json');","sourceCodeStart":232,"sourceCodeEnd":268,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/package/src/typescript.js#L232-L268","documentation":"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.","triggerScenarios":"Passing a `tsconfig` option/flag to svelte-package pointing at a directory or file where no tsconfig.json or jsconfig.json actually exists.","commonSituations":"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.","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."],"exampleFix":"// before\nsvelte-package --tsconfig ./configs\n\n// after\nsvelte-package --tsconfig ./configs/tsconfig.json","handlingStrategy":"validation","validationCode":"import fs from 'node:fs';\nconst p = './configs';\nif (!fs.existsSync(`${p}/tsconfig.json`) && !fs.existsSync(`${p}/jsconfig.json`)) {\n  throw new Error(`no tsconfig/jsconfig at ${p}`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await run(['svelte-package', '--tsconfig', './configs']);\n} catch (e) {\n  if (String(e.message).includes('Failed to locate provided tsconfig')) {\n    throw new Error('Point --tsconfig at the directory containing tsconfig.json');\n  }\n  throw e;\n}","preventionTips":["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"],"tags":["typescript","tsconfig","path","configuration"],"backgroundTag":"tsconfig-not-found","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}