{"record":{"id":"88e4110003389dd4","repo":"remix-run/react-router","slug":"route-config-in-routeconfigfile-is-invalid","errorCode":null,"errorMessage":"Route config in \"${routeConfigFile}\" is invalid.","messagePattern":"Route config in \"(.+?)\" is invalid\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/react-router-dev/config/config.ts","lineNumber":675,"sourceCode":"      });\n\n      if (!result.valid) {\n        return err(result.message);\n      }\n\n      // Nest the route config under the resolved root route\n      routeConfig = [\n        {\n          id: \"root\",\n          path: \"\",\n          file: Path.relative(appDirectory, rootRouteFile),\n          children: result.routeConfig,\n        },\n      ];\n\n      routes = configRoutesToRouteManifest(appDirectory, routeConfig);\n    } catch (error: any) {\n      return err(\n        [\n          colors.red(`Route config in \"${routeConfigFile}\" is invalid.`),\n          \"\",\n          error.loc?.file && error.loc?.column && error.frame\n            ? [\n                Path.relative(appDirectory, error.loc.file) +\n                  \":\" +\n                  error.loc.line +\n                  \":\" +\n                  error.loc.column,\n                error.frame.trim?.(),\n              ]\n            : error.stack,\n        ]\n          .flat()\n          .join(\"\\n\"),\n      );\n    }","sourceCodeStart":657,"sourceCodeEnd":693,"githubUrl":"https://github.com/remix-run/react-router/blob/6beaca39526d5716c3c112ebb0782765baa5a9ce/packages/react-router-dev/config/config.ts#L657-L693","documentation":"Importing or validating `routes.ts` threw: either the Vite-runner import failed (syntax error, unresolvable import, top-level throw) or `validateRouteConfig` rejected the shape. When Vite supplies `error.loc`/`error.frame`, the message includes a `file:line:column` pointer and the annotated code frame, so the exact spot in the route config is shown beneath the header.","triggerScenarios":"A broken import in `app/routes.ts` (module not found); exporting a default that is not a valid `RouteConfig` array (e.g. an object or undefined); a helper like a custom `flatRoutes` call throwing; referencing a route file path that fails resolution inside the config.","commonSituations":"Renaming/moving route files without updating `routes.ts`; typos in `route(\"about\", \"./about.tssx\")`; a route config helper that reads the filesystem and throws on unexpected structure; TS features in `routes.ts` not supported by the loader after a Vite upgrade.","solutions":["Read the `file:line:column` and frame embedded in the error output — it points at the failing expression in the route config.","Fix the import/path/typo it identifies (missing module, bad file extension, wrong relative path).","Confirm the default export is a flat array of route config entries and `satisfies RouteConfig` typechecks.","Run `pnpm run typecheck` (or `tsc`) to catch type-level mistakes in `routes.ts`."],"exampleFix":"// before: app/routes.ts\nimport { route } from \"@react-router/dev/routes\";\nexport default [\n  route(\"about\", \"./abuot.tsx\"), // typo -> import fails, \"Route config ... is invalid\"\n];\n\n// after\nimport { route } from \"@react-router/dev/routes\";\nexport default [\n  route(\"about\", \"./about.tsx\"),\n] satisfies RouteConfig;","handlingStrategy":"try-catch","validationCode":"// fail fast on broken route file references before building\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nfor (const entry of routeConfigEntries) {\n  const file = path.join(\"app\", entry.file);\n  if (!fs.existsSync(file)) {\n    throw new Error(`Route config references missing file: ${entry.file}`);\n  }\n}","typeGuard":"function isRouteConfig(v: unknown): v is RouteConfigEntry[] {\n  return Array.isArray(v) && v.every((e) => typeof e?.file === \"string\");\n}","tryCatchPattern":"try {\n  const routesMod = await import(\"./app/routes.ts\");\n  const entries = routesMod.default;\n  if (!Array.isArray(entries)) throw new Error(\"routes.ts default export must be an array\");\n} catch (e: any) {\n  if (e.loc?.file) {\n    console.error(`${path.relative(process.cwd(), e.loc.file)}:${e.loc.line}:${e.loc.column}`);\n    console.error(e.frame?.trim());\n  }\n  process.exit(1);\n}","preventionTips":["End routes.ts with `satisfies RouteConfig` so TypeScript flags bad entries and paths.","Run typecheck in CI to catch route-file typos before the build.","After renaming/moving route files, grep routes.ts for stale paths."],"tags":["config","routes","validation","module-resolution","build"],"backgroundTag":"invalid-route-configuration","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"}