{"record":{"id":"65dc2d20b91804e7","repo":"remix-run/react-router","slug":"reactrouterconfigfile-must-provide-a-default-ex","errorCode":null,"errorMessage":"${reactRouterConfigFile} must provide a default export","messagePattern":"(.+?) must provide a default export","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/react-router-dev/config/config.ts","lineNumber":467,"sourceCode":"  viteRunnerContext: ViteRunner.Context;\n  reactRouterConfigFile?: string;\n  skipRoutes?: boolean;\n  validateConfig?: ValidateConfigFunction;\n}): Promise<ConfigResult> {\n  let reactRouterUserConfig: ReactRouterConfig = {};\n\n  if (reactRouterConfigFile) {\n    try {\n      if (!fs.existsSync(reactRouterConfigFile)) {\n        return err(`${reactRouterConfigFile} no longer exists`);\n      }\n\n      let configModule = await viteRunnerContext.runner.import(\n        reactRouterConfigFile,\n      );\n\n      if (configModule.default === undefined) {\n        return err(`${reactRouterConfigFile} must provide a default export`);\n      }\n\n      if (typeof configModule.default !== \"object\") {\n        return err(`${reactRouterConfigFile} must export a config`);\n      }\n\n      reactRouterUserConfig = configModule.default;\n\n      if (validateConfig) {\n        const error = validateConfig(reactRouterUserConfig);\n        if (error) {\n          return err(error);\n        }\n      }\n    } catch (error) {\n      return err(`Error loading ${reactRouterConfigFile}: ${error}`);\n    }\n  }","sourceCodeStart":449,"sourceCodeEnd":485,"githubUrl":"https://github.com/remix-run/react-router/blob/6beaca39526d5716c3c112ebb0782765baa5a9ce/packages/react-router-dev/config/config.ts#L449-L485","documentation":"The React Router config file was imported through the Vite runner, but its module has no `default` export (`configModule.default === undefined`). React Router requires the config file to export its configuration object as the default export, so config resolution returns this error before any validation runs.","triggerScenarios":"Writing `react-router.config.ts` with only named exports (e.g. `export const config = {...}`), exporting nothing, or exporting only types/side effects; the file loads fine but `mod.default` is undefined.","commonSituations":"Converting a shared config snippet into named exports and forgetting the `default` keyword; copy-pasting an example that uses `export default` into a file where it gets wrapped or re-exported without default; refactoring tools (codemods) stripping the default export.","solutions":["Add `export default` to the config object in the file named in the error.","If using a named export locally, add `export default config;` at the end of the file.","Verify there is exactly one default export and it is the top-level config object.","Restart the dev server after fixing (config is loaded once per readConfig call)."],"exampleFix":"// before: react-router.config.ts\nexport const config = {\n  ssr: true,\n};\n\n// after\nexport default {\n  ssr: true,\n};","handlingStrategy":"type-guard","validationCode":"// quick check before starting the toolchain\nimport fs from \"node:fs\";\nconst src = fs.readFileSync(\"react-router.config.ts\", \"utf8\");\nif (!/^export\\s+default\\b/m.test(src) && !/^export\\s*\\{[^}]*\\bas\\s+default\\b/m.test(src)) {\n  throw new Error(\"react-router.config.ts must have a default export\");\n}","typeGuard":"function hasDefaultConfig(mod: unknown): mod is { default: object } {\n  return (\n    typeof mod === \"object\" &&\n    mod !== null &&\n    \"default\" in mod &&\n    typeof (mod as { default: unknown }).default === \"object\"\n  );\n}","tryCatchPattern":null,"preventionTips":["Always author the config as `export default { ... }`.","If splitting config into helpers, still re-export the object as default at the end.","Codemod reviews of the config file should assert the default export survives."],"tags":["config","es-modules","default-export","build"],"backgroundTag":"missing-default-export","analyzedSha":"6beaca39526d5716c3c112ebb0782765baa5a9ce","analyzedAt":"2026-08-18T18:04:14.938Z","contentChangedAt":"2026-08-18T18:04:14.938Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}