{"record":{"id":"288d0edf90795db0","repo":"remix-run/react-router","slug":"react-router-config-loading-requires-vite-s-conf","errorCode":null,"errorMessage":"React Router config loading requires Vite's __config_loader environment to be runnable.","messagePattern":"React Router config loading requires Vite's __config_loader environment to be runnable\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/react-router-dev/vite/vite-runner.ts","lineNumber":66,"sourceCode":"    configFile: false,\n    envDir: false,\n    plugins: [],\n    environments: {\n      __config_loader: {\n        consumer: \"server\",\n        dev: {\n          createEnvironment: (name, config, context) =>\n            vite.createRunnableDevEnvironment(name, config),\n        },\n      },\n    },\n  });\n\n  const environment = devServer.environments.__config_loader;\n\n  if (!vite.isRunnableDevEnvironment(environment)) {\n    await devServer.close();\n    throw new Error(\n      \"React Router config loading requires Vite's __config_loader environment to be runnable.\",\n    );\n  }\n\n  return { devServer, environment, runner: environment.runner };\n}\n","sourceCodeStart":48,"sourceCodeEnd":73,"githubUrl":"https://github.com/remix-run/react-router/blob/6beaca39526d5716c3c112ebb0782765baa5a9ce/packages/react-router-dev/vite/vite-runner.ts#L48-L73","documentation":"When React Router loads react-router.config.ts, it boots an inline Vite dev server with a dedicated environment named '__config_loader', created through vite.createRunnableDevEnvironment. After creating the server it asserts vite.isRunnableDevEnvironment(environment); if that returns false — typically because user vite config or a plugin overrode environments.__config_loader.createEnvironment with a non-runnable environment, or the resolved Vite version's environment API doesn't match — config loading cannot execute and the error is thrown after closing the dev server.","triggerScenarios":"A vite.config.ts that defines environments.__config_loader (or a plugin hook that injects environment config matching every environment) with a custom non-runnable createEnvironment; a mismatched/duplicated Vite version resolved in the workspace.","commonSituations":"Adding per-environment config for client/ssr and accidentally covering __config_loader; monorepo/pnpm hoisting pulling a different vite instance than the one @react-router/dev expects; upgrading Vite major versions ahead of React Router support.","solutions":["Scope custom environments config to 'client' and 'ssr' only and remove any '__config_loader' key","Align the vite version with the peer range @react-router/dev requires (dedupe vite in the lockfile)","If a plugin injects environment factories, restrict it so it skips the __config_loader environment"],"exampleFix":"// before (vite.config.ts)\nexport default defineConfig({\n  environments: {\n    __config_loader: { createEnvironment: myCustomEnv }, // clobbers React Router's\n  },\n});\n\n// after\nexport default defineConfig({\n  environments: {\n    client: { /* ... */ },\n    ssr: { /* ... */ }, // leave __config_loader to React Router\n  },\n});","handlingStrategy":"validation","validationCode":"import { resolveConfig } from \"vite\";\nconst cfg = await resolveConfig({ configFile: \"vite.config.ts\" }, \"serve\");\nif (cfg.environments && \"__config_loader\" in cfg.environments) {\n  throw new Error(\"Remove custom __config_loader environment config — React Router owns it\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Scope environments config to 'client' and 'ssr' only","Pin/dedupe the vite version to the one @react-router/dev peers with","Re-check environment config after Vite major upgrades"],"tags":["vite","environments","dev-server","config","version-mismatch"],"backgroundTag":"vite-environment-misconfiguration","analyzedSha":"6beaca39526d5716c3c112ebb0782765baa5a9ce","analyzedAt":"2026-08-18T18:04:14.938Z","contentChangedAt":"2026-08-18T18:04:14.938Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}