parcel-bundler/parcel · error · ThrowableDiagnostic
Failed to parse .parcelrc
Error message
Failed to parse .parcelrc
What it means
Thrown by parseAndProcessConfig() when the JSON5 parse of .parcelrc contents fails. The error includes a code frame with the exact line and column from the parse exception (e.lineNumber / e.columnNumber) and the escaped parse error message.
Source
Thrown at packages/core/core/src/requests/ParcelConfigRequest.js:226
): Promise<ParcelConfigChain> {
return processConfigChain(config, config.filePath, options);
}
// eslint-disable-next-line require-await
export async function parseAndProcessConfig(
configPath: FilePath,
contents: string,
options: ParcelOptions,
): Promise<ParcelConfigChain> {
let config: RawParcelConfig;
try {
config = parse(contents);
} catch (e) {
let pos = {
line: e.lineNumber,
column: e.columnNumber,
};
throw new ThrowableDiagnostic({
diagnostic: {
message: `Failed to parse .parcelrc`,
origin: '@parcel/core',
codeFrames: [
{
filePath: configPath,
language: 'json5',
code: contents,
codeHighlights: [
{
start: pos,
end: pos,
message: escapeMarkdown(e.message),
},
],
},
],View on GitHub (pinned to 59484858a1)
Solutions
- Use the line/column in the diagnostic to jump to the exact error location.
- Validate the file as JSON5: npx json5 .parcelrc (parses and reports errors).
- Check for unclosed braces/brackets and stray trailing commas.
- Start from a known-good config: { "extends": "@parcel/config-default" } and add customizations incrementally.
- Use an editor with JSON5 syntax highlighting to catch errors visually.
Example fix
// before — .parcelrc (broken)
{
"extends": "@parcel/config-default"
"transformers": { "*.css": [...] }
}
// after
{
"extends": "@parcel/config-default",
"transformers": { "*.css": [...] }
} Defensive patterns
Strategy: validation
Validate before calling
const fs = require('fs');
const JSON5 = require('json5');
function validateParcelrcSyntax(parcelrcPath) {
const content = fs.readFileSync(parcelrcPath, 'utf8');
try {
JSON5.parse(content);
} catch (e) {
throw new Error(`Syntax error in ${parcelrcPath} at line ${e.lineNumber}: ${e.message}`);
}
} Prevention
- Use an editor with JSON5 syntax highlighting.
- Run npx json5 .parcelrc to validate syntax before building.
- Start from a minimal valid config and add changes incrementally.
When it happens
Trigger: Called during config chain processing. parse(contents) (JSON5 parser) throws on malformed syntax — unclosed braces, stray commas, invalid tokens. The catch block extracts line/column from the exception and builds a precise code-frame diagnostic.
Common situations: Hand-editing .parcelrc and introducing a syntax error; copy-pasting a config fragment with wrong quoting; missing closing brace/bracket; using YAML or JS-style comments in what should be JSON5; encoding issues (BOM, CRLF in some edge cases).
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Only one spread parameter can be included in a config pipeli
- Local plugins are not supported in Parcel config packages. P
- Error parsing ${path.relative(this.options.inputFS.cwd(), pk
- Could not find a .parcelrc
- Could not find parcel config at ${path.relative(options.proj
AI-assisted analysis of parcel-bundler/parcel@59484858a1 (2026-08-13).
Data as JSON: /api/errors/72f510a0248756d2.
Report an issue: GitHub.