{"record":{"id":"d7ea003b8bcfd2d2","repo":"remix-run/remix","slug":"rmx-routes-file-not-found-d7ea00","errorCode":"RMX_ROUTES_FILE_NOT_FOUND","errorMessage":"Could not find app/routes.ts. Run this command inside a Remix app.","messagePattern":"Could not find app/routes\\.ts\\. Run this command inside a Remix app\\.","errorType":"error_code","errorClass":"CliError","httpStatus":null,"severity":"error","filePath":"packages/cli/src/lib/route-map.ts","lineNumber":288,"sourceCode":"  if (typeof method !== 'string' || typeof pattern !== 'string') {\n    throw new Error(`Route-map loader returned an invalid route leaf for \"${name}\".`)\n  }\n\n  return {\n    children: [],\n    key,\n    kind,\n    method,\n    name,\n    pattern,\n  }\n}\n\nasync function findRemixAppRoot(startDir: string): Promise<string> {\n  let appRoot = await findAppRoot(startDir, 'app/routes.ts')\n\n  if (appRoot == null) {\n    throw routesFileNotFound(startDir)\n  }\n\n  return appRoot\n}\n\nfunction getRouteMapWorkerPath(): string {\n  let currentFilePath = fileURLToPath(import.meta.url)\n  let extension = currentFilePath.endsWith('.ts') ? '.ts' : '.js'\n\n  return fileURLToPath(new URL(`./load-route-map-worker${extension}`, import.meta.url))\n}\n\nfunction createRouteMapWorkerEnv(): NodeJS.ProcessEnv {\n  let env = { ...process.env }\n\n  for (let key of Object.keys(env)) {\n    if (key.startsWith('NODE_TEST_')) {\n      delete env[key]","sourceCodeStart":270,"sourceCodeEnd":306,"githubUrl":"https://github.com/remix-run/remix/blob/9696913134be3a4423513d2775f7b31d6917c049/packages/cli/src/lib/route-map.ts#L270-L306","documentation":"findRemixAppRoot walks up from startDir looking for `app/routes.ts`; if no ancestor directory contains it, the CLI cannot locate a Remix app and throws this error telling you to run the command inside a Remix app.","triggerScenarios":"Running a Remix CLI command in a directory that is not inside (or above) a project containing `app/routes.ts` — e.g. home dir, an empty folder, or a monorepo root where no ancestor has the file.","commonSituations":"cd'd into the wrong folder; scaffolding layout that puts the app in a nested workspace; deleted or renamed app/routes.ts.","solutions":["cd into your Remix app directory (the one containing `app/routes.ts`) and re-run","If app/routes.ts was renamed/deleted, restore it","Verify the project was actually created with the current Remix template"],"exampleFix":"# before (in ~)\nremix routes\n# after (in project)\ncd my-app && remix routes","handlingStrategy":"validation","validationCode":"import { stat } from 'node:fs/promises'\nimport path from 'node:path'\nconst findUp = async (dir: string): Promise<string | null> => {\n  const candidate = path.join(dir, 'app', 'routes.ts')\n  if (await stat(candidate).then(() => true, () => false)) return dir\n  const parent = path.dirname(dir)\n  return parent === dir ? null : findUp(parent)\n}","typeGuard":"const isRemixAppDir = (dir: string): Promise<boolean> =>\n  stat(path.join(dir, 'app', 'routes.ts')).then(() => true, () => false)","tryCatchPattern":"catch (error) {\n  if (error instanceof Error && error.code === 'RMX_ROUTES_FILE_NOT_FOUND') {\n    // prompt for the project directory\n  }\n  throw error\n}","preventionTips":["Run Remix CLI commands from the app root","Keep app/routes.ts at the conventional location"],"tags":["cli","routes","project-not-found"],"backgroundTag":"project-root-not-found","analyzedSha":"9696913134be3a4423513d2775f7b31d6917c049","analyzedAt":"2026-08-27T19:55:01.024Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}