{"id":"0e38b1905f9a27a6","repo":"prettier/prettier","slug":"can-not-find-configure-file-for-file","errorCode":null,"errorMessage":"Can not find configure file for \"${file}\".","messagePattern":"Can not find configure file for \"(.+?)\"\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/cli/find-config-path.js","lineNumber":11,"sourceCode":"import path from \"node:path\";\nimport { resolveConfigFile } from \"../index.js\";\nimport { normalizeToPosix, printToScreen } from \"./utilities.js\";\n\nasync function logResolvedConfigPathOrDie(context) {\n  const file = context.argv.findConfigPath;\n  const configFile = await resolveConfigFile(file);\n  if (configFile) {\n    printToScreen(normalizeToPosix(path.relative(process.cwd(), configFile)));\n  } else {\n    throw new Error(`Can not find configure file for \"${file}\".`);\n  }\n}\n\nexport default logResolvedConfigPathOrDie;\n","sourceCodeStart":1,"sourceCodeEnd":16,"githubUrl":"https://github.com/prettier/prettier/blob/315f28198200d7678dadd3fd5eece499b127ff2a/src/cli/find-config-path.js#L1-L16","documentation":"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`.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Add a Prettier config (`.prettierrc.json`, `.prettierrc`, or a `prettier` key in `package.json`) at or above the file's directory.","Confirm the file path is correct and inside the project tree.","If you intentionally have no config, `--find-config-path` will always fail; drop the flag."],"exampleFix":"# before (no config exists)\nprettier --find-config-path src/index.js\n# after\necho '{}' > .prettierrc.json && prettier --find-config-path src/index.js","handlingStrategy":"try-catch","validationCode":"import { resolveConfigFile } from 'prettier';\nasync function safeFindConfigPath(file) {\n  const cfg = await resolveConfigFile(file);\n  if (!cfg) return null; // caller decides\n  return cfg;\n}","typeGuard":null,"tryCatchPattern":"try {\n  await logResolvedConfigPathOrDie(context);\n} catch (err) {\n  if (/Can not find configure file/.test(err.message)) {\n    console.warn('No Prettier config found; create one or drop --find-config-path.');\n  } else throw err;\n}","preventionTips":["Add a `.prettierrc.json` (even `{}`) at the repo root before running config-resolution commands.","Treat a missing config as a soft signal in tooling, not an error.","Confirm the file path is inside the project tree."],"tags":["cli","config","filesystem"],"analyzedSha":"315f28198200d7678dadd3fd5eece499b127ff2a","analyzedAt":"2026-08-03T19:59:41.458Z","schemaVersion":2}