remix-run/react-router · error

Could not find a root route module in the app directory as "

Error message

Could not find a root route module in the app directory as "${rootRouteDisplayPath}"

What it means

`readConfig` searches the app directory for a root route module via `findEntry(appDirectory, "root")` (matching `root.tsx`, `root.ts`, `root.jsx`, etc.). If none is found, it reports the expected display path (e.g. `app/root.tsx`) and aborts — the root route is mandatory because the route manifest is nested under it and it defines the document shell.

Source

Thrown at packages/react-router-dev/config/config.ts:624

      return err(
        "The `routeDiscovery.manifestPath` config must be a root-relative " +
          'pathname beginning with a slash (i.e., "/__manifest")',
      );
    }

    routeDiscovery = userRouteDiscovery;
  }

  let appDirectory = Path.resolve(root, userAppDirectory || "app");
  let buildDirectory = Path.resolve(root, userBuildDirectory);

  let rootRouteFile = findEntry(appDirectory, "root", { absolute: true });
  if (!rootRouteFile) {
    let rootRouteDisplayPath = Path.relative(
      root,
      Path.join(appDirectory, "root.tsx"),
    );
    return err(
      `Could not find a root route module in the app directory as "${rootRouteDisplayPath}"`,
    );
  }

  let routes: RouteManifest;
  let routeConfig: RouteConfigEntry[] = [];

  if (skipRoutes) {
    routes = {};
  } else {
    let routeConfigFile = findEntry(appDirectory, "routes");

    try {
      if (!routeConfigFile) {
        let routeConfigDisplayPath = Path.relative(
          root,
          Path.join(appDirectory, "routes.ts"),
        );

View on GitHub (pinned to 6beaca3952)

Solutions

  1. Create the root route at the path shown in the error (default `app/root.tsx`) exporting a default component.
  2. If the file exists elsewhere, either move it into the app directory or fix the `appDirectory` config to point at the right folder.
  3. Include `<Outlet />` in the root layout so child routes render.
  4. Restart the dev server / rebuild.

Example fix

// before: app/root.tsx missing -> config error "Could not find a root route module..."

// after: create app/root.tsx
import { Outlet } from "react-router";

export default function Root() {
  return (
    <html>
      <body>
        <Outlet />
      </body>
    </html>
  );
}
Defensive patterns

Strategy: validation

Validate before calling

import fs from "node:fs";
import path from "node:path";
const appDir = path.resolve(process.cwd(), "app");
const hasRoot = ["root.tsx", "root.ts", "root.jsx", "root.js"].some((f) =>
  fs.existsSync(path.join(appDir, f)),
);
if (!hasRoot) throw new Error(`Missing root route module in ${appDir}`);

Prevention

When it happens

Trigger: Starting a project where `app/root.tsx` was never created, was renamed (e.g. `App.tsx`), or the `appDirectory` config points at a directory that does not contain it.

Common situations: Fresh manual setup (not via the template) missing the root file; renaming `root.tsx` while refactoring and deleting instead of moving; `appDirectory` misconfigured (e.g. `src` while the root lives in `app`); moving files during a layout reorganization while the dev server reloads config.

Related errors


AI-assisted analysis of remix-run/react-router@6beaca3952 (2026-08-18). Data as JSON: /api/errors/97e6d4d90a60e8e4. Report an issue: GitHub.