{"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/d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca/packages/astro/src/core/config/config.ts#L44-L80","documentation":"`resolveConfigPath` joins the `--config` argument with the project root and checks existence with `fs.existsSync`; if the file is absent it throws `ConfigNotFound`. This validates the explicitly-passed config path before Astro attempts to load it, giving a precise error instead of a confusing import failure.","triggerScenarios":"Running `astro dev --config ./astro.config.prod.mjs` (or `build`/`sync`) when that file does not exist relative to the project root. Also triggered by a script/package.json passing a stale `--config` path.","commonSituations":"Renaming/deleting a config file without updating the npm script; running the CLI from the wrong working directory so the relative path resolves elsewhere; typo in the `--config` value; CI using a config path that exists only in another branch.","solutions":["Verify the file exists at `<root>/<configFile>` (the root is the cwd or the value Astro computes).","Run the CLI from the project root so the relative path resolves correctly.","Update the npm script / CI command to point at the correct config filename.","Drop `--config` to let Astro auto-discover `astro.config.{mjs,ts,js}`."],"exampleFix":"// before\nastro dev --config ./config/astro.prod.mjs\n\n// after (fix path or remove flag)\nastro dev --config ./config/astro.prod.config.mjs\n// or\nastro dev","handlingStrategy":"validation","validationCode":"const fs = require('fs'); const path = require('path');\nif (configFile && !fs.existsSync(path.join(root, configFile))) {\n  throw new Error('Config file not found: ' + configFile);\n}","typeGuard":"function configExists(root, file) {\n  return !file || fs.existsSync(path.join(root, file));\n}","tryCatchPattern":null,"preventionTips":["Keep npm scripts' --config paths in sync with file renames.","Run CLI from the project root.","Let Astro auto-discover config when only one file is used."],"tags":["configuration","cli","config"],"backgroundTag":null,"analyzedSha":"d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca","analyzedAt":"2026-08-12T13:37:29.035Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}