{"record":{"id":"5e3d2ce780ac1ff5","repo":"remix-run/react-router","slug":"react-router-vite-plugin-not-found-in-vite-config","errorCode":null,"errorMessage":"React Router Vite plugin not found in Vite config","messagePattern":"React Router Vite plugin not found in Vite config","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"packages/react-router-dev/vite/build.ts","lineNumber":74,"sourceCode":"              },\n            };\n          }\n          if (sourcemapServer && name !== \"client\") {\n            return {\n              build: {\n                sourcemap: sourcemapServer,\n              },\n            };\n          }\n        },\n        configResolved(config) {\n          let hasReactRouterPlugin = config.plugins.find(\n            (plugin) =>\n              plugin.name === \"react-router\" ||\n              plugin.name === \"react-router/rsc\",\n          );\n          if (!hasReactRouterPlugin) {\n            throw new Error(\n              \"React Router Vite plugin not found in Vite config\",\n            );\n          }\n        },\n      },\n    ],\n  });\n  await builder.buildApp();\n}\n","sourceCodeStart":56,"sourceCodeEnd":84,"githubUrl":"https://github.com/remix-run/react-router/blob/1fd704a7dabcbe3ae09d7387b460e6acaba30ec1/packages/react-router-dev/vite/build.ts#L56-L84","documentation":"Thrown from the `react-router:cli-config` plugin's `configResolved` hook inside `build.ts`. After Vite resolves the merged config, the React Router CLI build scans `config.plugins` for an entry whose `name` is `react-router` or `react-router/rsc`. If none is present, the CLI cannot drive a Framework Mode build and aborts. This is a startup invariant: the `react-router` Vite plugin must be the one registered in the user's `vite.config.ts`, not just installed in `node_modules`.","triggerScenarios":"Calling `react-router build` (or `vite build` with the React Router CLI) against a `vite.config.ts` that does not spread `...reactRouter()` into the `plugins` array; or a config file at a non-default path that the CLI is not pointed at via `--config`; or only installing `@react-router/dev` as a dependency without actually invoking its default-export plugin in the config.","commonSituations":"New Framework Mode projects scaffolded without the plugin line; migrating a Declarative/Data-mode app to Framework Mode and forgetting to add `reactRouter()` to `plugins`; pointing the CLI at the wrong config via `--config`; an RSC project that registers `reactRouterRSC` under a different alias that lacks the `react-router/rsc` name.","solutions":["Open `vite.config.ts` and confirm `reactRouter()` is in the `plugins` array, e.g. `plugins: [reactRouter()]`.","Ensure the import is `import { reactRouter } from \"@react-router/dev\";` (Framework Mode) and that `@react-router/dev` is a real dependency.","If using a custom config path, pass it explicitly: `react-router build --config path/to/vite.config.ts`.","For RSC, use the RSC preset so the plugin registers as `react-router/rsc` rather than an arbitrary name.","Print `config.plugins.map(p => p.name)` in a throwaway `configResolved` hook to confirm what Vite actually merged."],"exampleFix":"// before\nimport { defineConfig } from \"vite\";\nexport default defineConfig({ plugins: [] });\n// after\nimport { reactRouter } from \"@react-router/dev\";\nexport default defineConfig({\n  plugins: [reactRouter()],\n});","handlingStrategy":"validation","validationCode":"// Before calling react-router build, sanity-check the resolved config\nimport { resolveConfig } from \"vite\";\nconst cfg = await resolveConfig({ configFile: \"./vite.config.ts\" }, \"build\");\nconst ok = cfg.plugins.some(p => p.name === \"react-router\" || p.name === \"react-router/rsc\");\nif (!ok) throw new Error(\"reactRouter() not registered in vite.config.ts\");","typeGuard":"const hasReactRouterPlugin = (plugins: { name: string }[]): boolean =>\n  plugins.some(p => p.name === \"react-router\" || p.name === \"react-router/rsc\");","tryCatchPattern":null,"preventionTips":["Always add `reactRouter()` to `plugins` in `vite.config.ts` for Framework Mode projects.","Pin `@react-router/dev` as a direct dependency, not transitive.","Add a CI step that runs `react-router build` on every PR to catch missing-plugin regressions."],"tags":["vite","framework-mode","config","build","cli"],"backgroundTag":null,"analyzedSha":"1fd704a7dabcbe3ae09d7387b460e6acaba30ec1","analyzedAt":"2026-08-12T13:54:57.804Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}