{"record":{"id":"5955b2a7d4206598","repo":"sveltejs/kit","slug":"failed-to-locate-tsconfig-or-jsconfig","errorCode":null,"errorMessage":"Failed to locate tsconfig or jsconfig","messagePattern":"Failed to locate tsconfig or jsconfig","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/package/src/typescript.js","lineNumber":284,"sourceCode":"\t\t\ttraversed_dirs.push(dir);\n\n\t\t\tconst tsconfig = path.join(dir, 'tsconfig.json');\n\t\t\tconst jsconfig = path.join(dir, 'jsconfig.json');\n\n\t\t\tif (fs.existsSync(tsconfig)) {\n\t\t\t\tconfig_filename = tsconfig;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tif (fs.existsSync(jsconfig)) {\n\t\t\t\tconfig_filename = jsconfig;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (!config_filename) {\n\t\tthrow new Error('Failed to locate tsconfig or jsconfig');\n\t}\n\n\tconst { error, config } = ts.readConfigFile(config_filename, ts.sys.readFile);\n\n\tif (error) {\n\t\tthrow new Error('Malformed tsconfig\\n' + JSON.stringify(error, null, 2));\n\t}\n\n\t// Do this so TS will not search for initial files which might take a while\n\tconfig.include = [];\n\tconfig.files = [];\n\tconst { options } = ts.parseJsonConfigFileContent(\n\t\tconfig,\n\t\tts.sys,\n\t\tpath.dirname(config_filename),\n\t\t{ sourceMap: false },\n\t\tconfig_filename\n\t);","sourceCodeStart":266,"sourceCodeEnd":302,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/package/src/typescript.js#L266-L302","documentation":"During auto-discovery, `load_tsconfig` manually traverses parent directories (because ts.findConfigFile misbehaves) looking for a tsconfig.json or jsconfig.json. If the traversal reaches the filesystem root without finding either, it throws this error.","triggerScenarios":"Running svelte-package in a project with no tsconfig.json or jsconfig.json anywhere between the input directory and the filesystem root, while TS processing/types generation is required.","commonSituations":"JS library project that never created a jsconfig; repo where the config lives far outside the packaged package in a monorepo layout the traversal misses; config file accidentally deleted or gitignored.","solutions":["Add a tsconfig.json (or at minimum a jsconfig.json) at the project root.","In monorepos, add a minimal tsconfig.json to the packaged package even if it only extends the root config.","Pass `--tsconfig <path>` explicitly to point at an existing config."],"exampleFix":"// before: no tsconfig in project\n\n// after: tsconfig.json at project root\n{\n  \"extends\": \"../tsconfig.base.json\",\n  \"include\": [\"src/**/*.ts\", \"src/**/*.svelte\"]\n}","handlingStrategy":"validation","validationCode":"import fs from 'node:fs';\nif (!fs.existsSync('tsconfig.json') && !fs.existsSync('jsconfig.json')) {\n  throw new Error('project needs a tsconfig.json or jsconfig.json');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await run(['svelte-package']);\n} catch (e) {\n  if (String(e.message).includes('Failed to locate tsconfig')) {\n    throw new Error('Add a tsconfig.json at the project root (it may just extend a base config)');\n  }\n  throw e;\n}","preventionTips":["Keep a tsconfig.json at every packaged package root in monorepos","Use `extends` so per-package configs stay minimal","Don't gitignore tsconfig/jsconfig files"],"tags":["typescript","tsconfig","configuration","monorepo"],"backgroundTag":"tsconfig-not-found","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}