{"record":{"id":"fdcc2509c0d5086a","repo":"withastro/astro","slug":"confignotfound","errorCode":"ConfigNotFound","errorMessage":"Unable to resolve `--config \"${configFile}\"`. Does the file exist?","messagePattern":"Unable to resolve `--config \"(.+?)\"`\\. Does the file exist\\?","errorType":"exception","errorClass":"AstroError","httpStatus":null,"severity":"error","filePath":"packages/astro/src/core/config/config.ts","lineNumber":62,"sourceCode":"}\n\ninterface ResolveConfigPathOptions {\n\troot: string;\n\tconfigFile?: string | false;\n\tfs: typeof fs;\n}\n\n/**\n * Resolve the file URL of the user's `astro.config.js|mjs|ts` file\n */\nexport async function resolveConfigPath(\n\toptions: ResolveConfigPathOptions,\n): Promise<string | undefined> {\n\tlet userConfigPath: string | undefined;\n\tif (options.configFile) {\n\t\tuserConfigPath = path.join(options.root, options.configFile);\n\t\tif (!options.fs.existsSync(userConfigPath)) {\n\t\t\tthrow new AstroError({\n\t\t\t\t...AstroErrorData.ConfigNotFound,\n\t\t\t\tmessage: AstroErrorData.ConfigNotFound.message(options.configFile),\n\t\t\t});\n\t\t}\n\t} else {\n\t\tuserConfigPath = await search(options.fs, options.root);\n\t}\n\n\treturn userConfigPath;\n}\n\nasync function loadConfig(\n\troot: string,\n\tconfigFile?: string | false,\n\tfsMod = fs,\n): Promise<Record<string, any>> {\n\tif (configFile === false) return {};\n","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/withastro/astro/blob/52e6c34790cc8ac4e69e6135ace06049867e5c4a/packages/astro/src/core/config/config.ts#L44-L80","documentation":"`ConfigNotFound` is thrown by `resolveConfigPath` when you pass `--config <file>` and `path.join(root, configFile)` fails an `fs.existsSync` check. Without `--config`, Astro auto-searches for a config instead and never throws this. Note the path is joined to the project root (or the `--root` directory), not the current working directory.","triggerScenarios":"Running `astro dev --config astro.config.prod.ts` (or build/preview/sync) when that file does not exist under the project root; passing a path computed for a different `--root`; typo in the filename.","commonSituations":"Renamed or deleted config file while CI scripts still reference the old name; config path written relative to the repo root but the command runs with a different `--root`; simple typo.","solutions":["Verify the file exists at `<root>/<configFile>` (e.g. `ls astro.config.prod.ts` from the project root).","Fix the filename or path in the CLI flag or npm script.","Create the missing config file if it was supposed to exist.","Drop `--config` entirely to let Astro auto-discover the default config."],"exampleFix":"# before\nastro dev --config astro.config.prod.ts   # file does not exist at root\n\n# after\nastro dev --config astro.config.production.ts  # exact filename at project root","handlingStrategy":"validation","validationCode":"// Wrapper script around astro CLI calls\nimport { existsSync } from 'node:fs';\nimport path from 'node:path';\nconst cfg = path.resolve(process.cwd(), 'astro.config.prod.ts');\nif (!existsSync(cfg)) {\n  throw new Error(`Missing config file: ${cfg}`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep one canonical config filename documented in the repo README or npm scripts.","Add an existence check in CI scripts that pass `--config`.","Remember the path resolves against the project root (`--root`), not the shell's cwd."],"tags":["cli","config","filesystem"],"backgroundTag":"config-file-not-found","analyzedSha":"52e6c34790cc8ac4e69e6135ace06049867e5c4a","analyzedAt":"2026-08-18T18:48:03.901Z","contentChangedAt":"2026-08-18T18:48:03.901Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}