{"record":{"id":"72f510a0248756d2","repo":"parcel-bundler/parcel","slug":"failed-to-parse-parcelrc","errorCode":null,"errorMessage":"Failed to parse .parcelrc","messagePattern":"Failed to parse \\.parcelrc","errorType":"exception","errorClass":"ThrowableDiagnostic","httpStatus":null,"severity":"error","filePath":"packages/core/core/src/requests/ParcelConfigRequest.js","lineNumber":226,"sourceCode":"): Promise<ParcelConfigChain> {\n  return processConfigChain(config, config.filePath, options);\n}\n\n// eslint-disable-next-line require-await\nexport async function parseAndProcessConfig(\n  configPath: FilePath,\n  contents: string,\n  options: ParcelOptions,\n): Promise<ParcelConfigChain> {\n  let config: RawParcelConfig;\n  try {\n    config = parse(contents);\n  } catch (e) {\n    let pos = {\n      line: e.lineNumber,\n      column: e.columnNumber,\n    };\n    throw new ThrowableDiagnostic({\n      diagnostic: {\n        message: `Failed to parse .parcelrc`,\n        origin: '@parcel/core',\n\n        codeFrames: [\n          {\n            filePath: configPath,\n            language: 'json5',\n            code: contents,\n            codeHighlights: [\n              {\n                start: pos,\n                end: pos,\n                message: escapeMarkdown(e.message),\n              },\n            ],\n          },\n        ],","sourceCodeStart":208,"sourceCodeEnd":244,"githubUrl":"https://github.com/parcel-bundler/parcel/blob/59484858a1a0bcbb71f74088956bb437a2db6505/packages/core/core/src/requests/ParcelConfigRequest.js#L208-L244","documentation":"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.","triggerScenarios":"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.","commonSituations":"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).","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."],"exampleFix":"// before — .parcelrc (broken)\n{\n  \"extends\": \"@parcel/config-default\"\n  \"transformers\": { \"*.css\": [...] }\n}\n\n// after\n{\n  \"extends\": \"@parcel/config-default\",\n  \"transformers\": { \"*.css\": [...] }\n}","handlingStrategy":"validation","validationCode":"const fs = require('fs');\nconst JSON5 = require('json5');\nfunction validateParcelrcSyntax(parcelrcPath) {\n  const content = fs.readFileSync(parcelrcPath, 'utf8');\n  try {\n    JSON5.parse(content);\n  } catch (e) {\n    throw new Error(`Syntax error in ${parcelrcPath} at line ${e.lineNumber}: ${e.message}`);\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["parcelrc","json5","config","syntax-error","parse"],"backgroundTag":null,"analyzedSha":"59484858a1a0bcbb71f74088956bb437a2db6505","analyzedAt":"2026-08-13T04:06:35.925Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}