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>)

Diagnose it: config resolution and version drift

Lint failures that appear only in CI are almost always a different linter version or a different resolved configuration, not new violations in the code.

Terminal
npx eslint --version
npx eslint --print-config path/to/file.ts | head -40
npx eslint --debug path/to/file.ts 2>&1 | grep -i "config" | head

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 ESLint "Cannot read config file (.eslintrc)"?
There are 2 common causes: malformed json/js in the config and comments in a strict json config. A trailing comma, missing quote, or stray token makes .eslintrc.json invalid JSON, or a syntax error breaks .eslintrc.js.
How do I fix ESLint "Cannot read config file (.eslintrc)"?
There are 2 fixes depending on which cause you have: fix the config syntax and validate the config in ci before linting. Work through them in order, since the first is the most common.
What does ESLint "Cannot read config file (.eslintrc)" actually mean?
ESLint aborts with Cannot read config file: /app/.eslintrc.json and an underlying parse error (e.g.
How do I stop ESLint "Cannot read config file (.eslintrc)" happening again?
Keep .eslintrc.json valid JSON (no comments, no trailing commas). The prevention section lists 3 changes that keep it from recurring.

Related guides

References

Not every red build is your code. Latchkey repairs the ones that are not, on the runner. Start free → 30-day trial · No credit card