withastro/astro · warning
Couldn't parse tsconfig.json or jsconfig.json: ${inputConfig
Error message
Couldn't parse tsconfig.json or jsconfig.json: ${inputConfig.message} What it means
When `astro add <integration>` syncs editor settings, it loads your tsconfig.json (or jsconfig.json). If TypeScript reports parse diagnostics — broken JSON syntax or an unresolvable `extends` — Astro logs this warning and returns 'failure': your tsconfig was NOT updated, so the integration's compiler options and generated typings were not wired up. The rest of `astro add` (dependency install, astro.config edit) still completes; only the TS-config step is skipped.
Source
Thrown at packages/astro/src/cli/add/index.ts:983
options?: { addIncludes?: string[] },
): Promise<UpdateResult> {
const integrations = integrationsInfo.map(
(integration) => integration.id as frameworkWithTSSettings,
);
const includesToAppend = Array.from(new Set((options?.addIncludes ?? []).filter(Boolean)));
const firstIntegrationWithTSSettings = integrations.find((integration) =>
presets.has(integration),
);
if (!firstIntegrationWithTSSettings && includesToAppend.length === 0) {
return 'none';
}
let inputConfig = await loadTSConfig(cwd);
let inputConfigText = '';
if (inputConfig.error === 'invalid-config') {
logger.warn(`add`, `Couldn't parse tsconfig.json or jsconfig.json: ${inputConfig.message}`);
return 'failure';
} else if (inputConfig.error === 'missing-config') {
logger.debug('add', "Couldn't find tsconfig.json or jsconfig.json, generating one");
const tsconfigFile = path.join(cwd, 'tsconfig.json');
inputConfig = {
tsconfig: defaultTSConfig,
tsconfigFile: tsconfigFile,
rawConfig: defaultTSConfig,
sources: [tsconfigFile],
};
} else {
inputConfigText = JSON.stringify(inputConfig.rawConfig, null, 2);
}
const configFileName = path.basename(inputConfig.tsconfigFile);
let outputConfig = firstIntegrationWithTSSettings
? updateTSConfigForFramework(inputConfig.rawConfig, firstIntegrationWithTSSettings)View on GitHub (pinned to e294953aa8)
Solutions
- Surface the syntax error: `npx tsc -p . --noEmit` or `npx astro check` — both parse the config and report the offending line
- Fix the JSON syntax (or install the missing `extends` package), then rerun `astro add <integration>`
- Confirm the rerun actually patched tsconfig (astro add prints the diff it intends to apply)
- If you intentionally skip TS setup, the warning is harmless — integrate typings manually via a reference to the integration's types
Example fix
// before: tsconfig.json with a syntax error
{ "extends": "astro/tsconfigs/strict", } // trailing junk or missing brace
// after
{ "extends": "astro/tsconfigs/strict" } Defensive patterns
Strategy: validation
Validate before calling
// Run before `astro add` to catch a broken config early
import { readFileSync } from 'node:fs';
import ts from 'typescript';
const parsed = ts.readConfigFile('tsconfig.json', ts.sys.readFile);
if (parsed.error) {
console.error(ts.flattenDiagnosticMessageText(parsed.error, '\n'));
process.exit(1);
} Prevention
- Keep tsconfig.json valid JSONC — no stray characters beyond comments
- Add `astro check` or `tsc -p .` to CI so config parse errors surface before astro add runs
- After astro add reports 'failure', always rerun it once the config is fixed — the sync step never retried itself
When it happens
Trigger: Running `astro add` in a project whose tsconfig.json has a syntax error (missing brace/quote, stray comma, leftover merge-conflict markers) or an `extends` pointing at a package/file that does not exist.
Common situations: Hand-edited tsconfig with a typo; merge conflicts resolved badly; `extends` referencing an uninstalled base config; the file sits outside common JSONC pitfalls but contains genuine garbage.
Related errors
- Unknown error parsing tsconfig.json or jsconfig.json. Could
- Invalid package name "${packageName}". Package names must fo
- No problem! Find our official integrations at https://astro.
- Unable to fetch ${integration}. Does the package exist?
- ${packageName} doesn't appear to be an integration or an ada
AI-assisted analysis of withastro/astro@e294953aa8 (2026-08-18).
Data as JSON: /api/errors/28da9514f71494d0.
Report an issue: GitHub.