prettier/prettier · error · Error

Can not find configure file for "${file}".

Error message

Can not find configure file for "${file}".

What it means

Thrown by `logResolvedConfigPathOrDie` when `prettier.resolveConfigFile(file)` returns a falsy value, meaning Prettier walked up the directory tree from the given file and found no `.prettierrc`, `package.json#prettier`, or any other recognized config source. The CLI surfaces this as a hard error for `--find-config-path`.

Source

Thrown at src/cli/find-config-path.js:11

import path from "node:path";
import { resolveConfigFile } from "../index.js";
import { normalizeToPosix, printToScreen } from "./utilities.js";

async function logResolvedConfigPathOrDie(context) {
  const file = context.argv.findConfigPath;
  const configFile = await resolveConfigFile(file);
  if (configFile) {
    printToScreen(normalizeToPosix(path.relative(process.cwd(), configFile)));
  } else {
    throw new Error(`Can not find configure file for "${file}".`);
  }
}

export default logResolvedConfigPathOrDie;

View on GitHub (pinned to 315f281982)

Solutions

  1. Add a Prettier config (`.prettierrc.json`, `.prettierrc`, or a `prettier` key in `package.json`) at or above the file's directory.
  2. Confirm the file path is correct and inside the project tree.
  3. If you intentionally have no config, `--find-config-path` will always fail; drop the flag.

Example fix

# before (no config exists)
prettier --find-config-path src/index.js
# after
echo '{}' > .prettierrc.json && prettier --find-config-path src/index.js
Defensive patterns

Strategy: try-catch

Validate before calling

import { resolveConfigFile } from 'prettier';
async function safeFindConfigPath(file) {
  const cfg = await resolveConfigFile(file);
  if (!cfg) return null; // caller decides
  return cfg;
}

Try / catch

try {
  await logResolvedConfigPathOrDie(context);
} catch (err) {
  if (/Can not find configure file/.test(err.message)) {
    console.warn('No Prettier config found; create one or drop --find-config-path.');
  } else throw err;
}

Prevention

When it happens

Trigger: Running `prettier --find-config-path some/file.js` where neither the file's directory nor any ancestor contains a Prettier config. Also occurs when `EDITORCONFIG`/config search is disabled via env or the project simply has no Prettier config.

Common situations: Running the flag before adding a config file to a new project; pointing at a file outside the project root (e.g. in `/tmp`); monorepo where the file is in a package without its own config and root config is unreachable; typos in the file path.

Related errors


AI-assisted analysis of prettier/prettier@315f281982 (2026-08-03). Data as JSON: /data/errors/0e38b1905f9a27a6.json. Report an issue: GitHub.