{"record":{"id":"cd483156dbb381b9","repo":"angular/angular-cli","slug":"proxy-configuration-file-proxypath-contains-par","errorCode":null,"errorMessage":"Proxy configuration file ${proxyPath} contains parse errors:","messagePattern":"Proxy configuration file (.+?) contains parse errors:","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/angular_devkit/build_angular/src/tools/webpack/configs/dev-server.ts","lineNumber":185,"sourceCode":"  }\n\n  let proxyConfiguration;\n\n  switch (extname(proxyPath)) {\n    case '.json': {\n      const content = await fsPromises.readFile(proxyPath, 'utf-8');\n\n      const { parse, printParseErrorCode } = await import('jsonc-parser');\n      const parseErrors: import('jsonc-parser').ParseError[] = [];\n      proxyConfiguration = parse(content, parseErrors, { allowTrailingComma: true });\n\n      if (parseErrors.length > 0) {\n        let errorMessage = `Proxy configuration file ${proxyPath} contains parse errors:`;\n        for (const parseError of parseErrors) {\n          const { line, column } = getJsonErrorLineColumn(parseError.offset, content);\n          errorMessage += `\\n[${line}, ${column}] ${printParseErrorCode(parseError.error)}`;\n        }\n        throw new Error(errorMessage);\n      }\n\n      break;\n    }\n    default: {\n      try {\n        proxyConfiguration = await import(proxyPath);\n      } catch (e) {\n        assertIsError(e);\n        if (e.code !== 'ERR_REQUIRE_ASYNC_MODULE') {\n          throw e;\n        }\n\n        proxyConfiguration = await loadEsmModule<{ default: unknown }>(pathToFileURL(proxyPath));\n      }\n\n      break;\n    }","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/angular_devkit/build_angular/src/tools/webpack/configs/dev-server.ts#L167-L203","documentation":"For a `.json` proxy config, the dev-server config parses the file with the JSON scanner and collects parse errors. This error is thrown when the proxy JSON is syntactically invalid; the message lists each error with its [line, column] and a parse error code. It prevents serving with a malformed proxy configuration.","triggerScenarios":"`ng serve` with a `proxyConfig` ending in `.json` whose content fails JSON parsing (trailing commas, comments, single quotes, missing braces) — `parseErrors.length > 0` in `addProxyConfig`.","commonSituations":"Hand-editing proxy.conf.json and leaving a trailing comma or comment; copy-pasting a `proxy.conf.js` (JavaScript syntax) into a `.json` file; BOM or stray characters; merge-conflict markers left in the file.","solutions":["Fix the JSON syntax at the reported [line, column] from the error message (remove trailing commas, comments, single quotes).","Validate the file with `node -e \"JSON.parse(require('fs').readFileSync('proxy.conf.json'))\"` or an editor JSON linter.","If you need comments/JS logic, rename the file to proxy.conf.js and export a config object instead of keeping it as .json.","Regenerate a clean proxy.conf.json (e.g. `ng g config` style examples) and re-add your proxy entries."],"exampleFix":"// before: proxy.conf.json\n{ \"/api\": { \"target\": \"http://localhost:3000\", \"secure\": false, }, }\n// after\n{\n  \"/api\": { \"target\": \"http://localhost:3000\", \"secure\": false }\n}","handlingStrategy":"validation","validationCode":"import * as fs from 'fs';\nconst content = fs.readFileSync('proxy.conf.json', 'utf8');\ntry { JSON.parse(content); } catch (e) {\n  throw new Error(`proxy.conf.json is invalid JSON: ${e.message}`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate proxy.conf.json with a JSON linter or JSON.parse in CI.","No comments or trailing commas in .json files; use proxy.conf.js if you need them.","Check for merge-conflict markers after branching."],"tags":["angular","dev-server","proxy","json","syntax-error"],"backgroundTag":"invalid-json-config","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}