angular/angular-cli · error · Error
Proxy configuration file ${proxyPath} contains parse errors:
Error message
Proxy configuration file ${proxyPath} contains parse errors: What it means
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.
Source
Thrown at packages/angular_devkit/build_angular/src/tools/webpack/configs/dev-server.ts:185
}
let proxyConfiguration;
switch (extname(proxyPath)) {
case '.json': {
const content = await fsPromises.readFile(proxyPath, 'utf-8');
const { parse, printParseErrorCode } = await import('jsonc-parser');
const parseErrors: import('jsonc-parser').ParseError[] = [];
proxyConfiguration = parse(content, parseErrors, { allowTrailingComma: true });
if (parseErrors.length > 0) {
let errorMessage = `Proxy configuration file ${proxyPath} contains parse errors:`;
for (const parseError of parseErrors) {
const { line, column } = getJsonErrorLineColumn(parseError.offset, content);
errorMessage += `\n[${line}, ${column}] ${printParseErrorCode(parseError.error)}`;
}
throw new Error(errorMessage);
}
break;
}
default: {
try {
proxyConfiguration = await import(proxyPath);
} catch (e) {
assertIsError(e);
if (e.code !== 'ERR_REQUIRE_ASYNC_MODULE') {
throw e;
}
proxyConfiguration = await loadEsmModule<{ default: unknown }>(pathToFileURL(proxyPath));
}
break;
}View on GitHub (pinned to bb72145f9a)
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.
Example fix
// before: proxy.conf.json
{ "/api": { "target": "http://localhost:3000", "secure": false, }, }
// after
{
"/api": { "target": "http://localhost:3000", "secure": false }
} Defensive patterns
Strategy: validation
Validate before calling
import * as fs from 'fs';
const content = fs.readFileSync('proxy.conf.json', 'utf8');
try { JSON.parse(content); } catch (e) {
throw new Error(`proxy.conf.json is invalid JSON: ${e.message}`);
} Prevention
- 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.
When it happens
Trigger: `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`.
Common situations: 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.
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
- Proxy configuration file ${proxyPath} does not exist.
- Header "forwarded" proto parameter must be either "http" or
- Header "x-forwarded-port" must be a numeric value.
- Header "x-forwarded-proto" must be either "http" or "https".
- Header "x-forwarded-prefix" is invalid. It must start with a
AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30).
Data as JSON: /api/errors/cd483156dbb381b9.
Report an issue: GitHub.