{"record":{"id":"29ccba274cce8b54","repo":"remix-run/react-router","slug":"the-react-router-vite-plugin-requires-the-use-of-a","errorCode":null,"errorMessage":"The React Router Vite plugin requires the use of a Vite config file","messagePattern":"The React Router Vite plugin requires the use of a Vite config file","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"packages/react-router-dev/vite/plugin.ts","lineNumber":1429,"sourceCode":"          };\n        }\n      },\n      async configResolved(resolvedViteConfig) {\n        await initEsModuleLexer;\n\n        viteConfig = resolvedViteConfig;\n        invariant(viteConfig);\n\n        // We load the same Vite config file again for the child compiler so\n        // that both parent and child compiler's plugins have independent state.\n        // If we re-used the `viteUserConfig.plugins` array for the child\n        // compiler, it could lead to mutating shared state between plugin\n        // instances in unexpected ways, e.g. during `vite build` the\n        // `configResolved` plugin hook would be called with `command = \"build\"`\n        // by parent and then `command = \"serve\"` by child, which some plugins\n        // may respond to by updating state referenced by the parent.\n        if (!viteConfig.configFile) {\n          throw new Error(\n            \"The React Router Vite plugin requires the use of a Vite config file\",\n          );\n        }\n\n        let vite = getVite();\n\n        let childCompilerConfigFile = await vite.loadConfigFromFile(\n          {\n            command: viteConfig.command,\n            mode: viteConfig.mode,\n          },\n          viteConfig.configFile,\n        );\n\n        invariant(\n          childCompilerConfigFile,\n          \"Vite config file was unable to be resolved for React Router child compiler\",\n        );","sourceCodeStart":1411,"sourceCodeEnd":1447,"githubUrl":"https://github.com/remix-run/react-router/blob/1fd704a7dabcbe3ae09d7387b460e6acaba30ec1/packages/react-router-dev/vite/plugin.ts#L1411-L1447","documentation":"Thrown in the `configResolved` hook when the React Router plugin bootstraps its child compiler. To give the child compiler independent plugin state, React Router reloads the user's config via `vite.loadConfigFromFile` using `viteConfig.configFile`. If `configFile` is falsy — meaning Vite was driven purely by inline options or auto-discovery without recording a file — React Router cannot create an isolated plugin set and aborts.","triggerScenarios":"Running the React Router plugin against a Vite invocation that has no `vite.config.{ts,js,mjs}` on disk (e.g. `vite build` with `--config` pointing at nothing, or a programmatic `createServer({ configFile: false })`); a config file that failed to load and silently left `configFile` undefined; a monorepo where the wrong package's directory is the CWD.","commonSituations":"Programmatically invoking Vite from a script with `configFile: false`; running tools that wrap Vite (Storybook, custom SSR harnesses) without a real config file; an empty `.vite/config` after a botched setup.","solutions":["Create a `vite.config.ts` at the project root that registers `reactRouter()`.","If using `--config`, ensure the path resolves to an existing file.","Avoid `configFile: false` when programmatically building with the React Router plugin.","Run from the package directory that owns the `vite.config.ts`."],"exampleFix":"// before: programmatic build with no config file\nawait createServer({ configFile: false, plugins: [reactRouter()] });\n// after: ship a real vite.config.ts and let Vite load it\n// vite.config.ts\nimport { reactRouter } from \"@react-router/dev\";\nexport default defineConfig({ plugins: [reactRouter()] });","handlingStrategy":"validation","validationCode":"import { existsSync } from \"node:fs\";\nconst ensureConfigFile = (p = \"./vite.config.ts\") => {\n  if (!existsSync(p)) throw new Error(`Missing Vite config file: ${p}`);\n};","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always run React Router against a real `vite.config.ts` on disk.","Never pass `configFile: false` programmatically when using the React Router plugin.","Pin a startup self-check that the config file exists before invoking the CLI."],"tags":["vite","config","child-compiler","framework-mode"],"backgroundTag":null,"analyzedSha":"1fd704a7dabcbe3ae09d7387b460e6acaba30ec1","analyzedAt":"2026-08-12T13:54:57.804Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}