musistudio/claude-code-router · error · Error

Claude Code global config file is not valid JSON: ${file}. $

Error message

Claude Code global config file is not valid JSON: ${file}. ${formatError(error)}

What it means

Error "Claude Code global config file is not valid JSON: ${file}. ${formatError(error)}" thrown in musistudio/claude-code-router.

Source

Thrown at packages/core/src/profiles/service.ts:2204

    ...current,
    autoCompactWindowsCache: createClaudeCliAutoCompactWindows(config)
  };
  const writeResult = writeFileWithBackup(file, `${JSON.stringify(next, null, 2)}\n`, { mode: privateFileMode });
  return { ...writeResult, file };
}

function readClaudeCodeGlobalConfigObject(file: string): Record<string, unknown> {
  if (!existsSync(file)) {
    return {};
  }
  try {
    const parsed = JSON.parse(readFileSync(file, "utf8")) as unknown;
    if (isRecord(parsed)) {
      return parsed;
    }
    throw new Error("root value is not an object");
  } catch (error) {
    throw new Error(`Claude Code global config file is not valid JSON: ${file}. ${formatError(error)}`);
  }
}

function codexMiddlewareRuntimeFilename(): string {
  return "ccr-codex-cli-middleware.js";
}

function codexMiddlewareFilename(profile: ProfileConfig, providerId: string): string {
  const slug = sanitizeCodexProviderId(profile.id || profile.name || providerId) || "codex";
  return process.platform === "win32"
    ? `ccr-codex-cli-stdio-${slug}.cmd`
    : `ccr-codex-cli-stdio-${slug}`;
}

function shellProfileSurfaceExports(surface: "auto" | "cli" | "app"): string[] {
  return [
    "if [ -z \"${CCR_PROFILE_SURFACE:-}\" ]; then",
    "  case \"${1:-}\" in",

View on GitHub (pinned to 99f24806c6)

When it happens

Trigger: Thrown at packages/core/src/profiles/service.ts:2204 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of musistudio/claude-code-router@99f24806c6 (2026-08-27). Data as JSON: /api/errors/8d36d4649c92693e. Report an issue: GitHub.