Skip to content
Latchkey

ESLint "Cannot read config file (.eslintrc)" - Fix Bad Config in CI

ESLint found the config file but could not read or parse it - invalid JSON/JS, a syntax error, or a file it cannot open. Config loading fails before any file is linted.

What this error means

ESLint aborts with Cannot read config file: /app/.eslintrc.json and an underlying parse error (e.g. Unexpected token } in JSON). It is deterministic and tied to the config file itself.

eslint
Cannot read config file: /app/.eslintrc.json
Error: Unexpected token } in JSON at position 142
    at JSON.parse (<anonymous>)

Common causes

Malformed JSON/JS in the config

A trailing comma, missing quote, or stray token makes .eslintrc.json invalid JSON, or a syntax error breaks .eslintrc.js.

Comments in a strict JSON config

.eslintrc.json is parsed as strict JSON (no comments); a // or /* */ comment makes it unreadable. Use .eslintrc.cjs/.js if you need comments.

How to fix it

Fix the config syntax

  1. Open the config at the reported position and correct the JSON/JS syntax (trailing comma, missing quote).
  2. Validate JSON with node -e "require('./.eslintrc.json')" or a JSON linter.
  3. Move to .eslintrc.cjs if you need comments or dynamic logic.

Validate the config in CI before linting

Print the resolved config to confirm it loads.

Terminal
npx eslint --print-config src/index.ts > /dev/null && echo "config OK"

How to prevent it

  • Keep .eslintrc.json valid JSON (no comments, no trailing commas).
  • Use .eslintrc.cjs when you need comments or logic.
  • Validate the config with eslint --print-config in CI.

Frequently asked questions

What causes ""Cannot read config file""?
A trailing comma, missing quote, or stray token makes .eslintrc.json invalid JSON, or a syntax error breaks .eslintrc.js.
How do I fix "Cannot read config file"?
Fix the config syntax

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card