vercel/next.js · error · Error
Could not parsetsconfig.json. Please make sure it contains s
Error message
Could not parsetsconfig.json. Please make sure it contains syntactically correct JSON.
What it means
Thrown by getTypeScriptConfiguration() when parsing tsconfig.json raises a SyntaxError, meaning the file is not valid JSON (trailing commas, comments in non-JSON5 mode, unquoted keys, etc.). Next.js reads tsconfig.json to configure TypeScript path aliases and compiler options during dev/build, so it must be syntactically valid JSON.
Source
Thrown at packages/next/src/lib/typescript/getTypeScriptConfiguration.ts:63
result.errors = result.errors.filter(
({ code }) =>
// No inputs were found in config file
code !== 18003
)
}
if (result.errors?.length) {
// TODO: Throw AggregateError for all diagnostics.
throw new Error(
typescript.formatDiagnostic(result.errors[0], formatDiagnosticsHost)
)
}
return result
} catch (err) {
if (isError(err) && err.name === 'SyntaxError') {
const reason = '\n' + (err.message ?? '')
throw new Error(
bold(
'Could not parse' +
cyan('tsconfig.json') +
'.' +
' Please make sure it contains syntactically correct JSON.'
) + reason
)
}
throw err
}
}
View on GitHub (pinned to 0ae8c72462)
Solutions
- Open tsconfig.json and run it through a JSON validator (e.g. `npx tsconfig.json` lint or jsonlint) to find the syntax error.
- Remove trailing commas, comments, and ensure all keys/strings use double quotes.
- Use `tsc --showConfig` to confirm TypeScript itself can parse the file.
- If you rely on comments/extends, note tsconfig allows comments via the TS loader, but the underlying readConfigFile must still succeed — fix the specific SyntaxError shown in the message's appended reason.
Example fix
// before (tsconfig.json - invalid)
{
"compilerOptions": {
"strict": true, // trailing comment
"target": "ES2020",
}
}
// after
{
"compilerOptions": {
"strict": true,
"target": "ES2020"
}
} Defensive patterns
Strategy: validation
Validate before calling
import { readFileSync } from 'fs'
function validateTsconfig(path: string) {
try { JSON.parse(readFileSync(path, 'utf8')) }
catch (e) { throw new Error(`tsconfig.json is not valid JSON: ${e.message}`) }
} Prevention
- Validate tsconfig.json with a JSON linter after every edit.
- Use `tsc --showConfig` to confirm TypeScript can parse it.
- Avoid trailing commas and comments unless you confirm the TS loader accepts them.
- Add a preinstall or lint step that checks tsconfig validity.
When it happens
Trigger: tsconfig.json contains a JSON syntax error: trailing comma, single-quoted strings, unquoted property names, or a stray comment when read via typescript.readConfigFile that ultimately surfaces as a SyntaxError. The catch block at line 60 detects err.name === 'SyntaxError' and re-throws this friendly message.
Common situations: Hand-editing tsconfig.json and introducing a typo; copying a config snippet that uses JSON5 features; a merge conflict leaving invalid JSON; an editor auto-formatting that corrupts the file.
Related errors
- Could not parse output from TypeScript's --showConfig.
- NEXT_EXPORT_ERROR
- Failed to resolve pattern "${patterns.join(',')}": ${error.m
- The key "${key}" under "env" in ${config.configFileName || '
- It looks like you're trying to use TypeScript but do not hav
AI-assisted analysis of vercel/next.js@0ae8c72462 (2026-08-06).
Data as JSON: /api/errors/eeb446139b672574.
Report an issue: GitHub.