remix-run/remix · error · CliError
RMX_ROUTES_FILE_NOT_FOUND
RMX_ROUTES_FILE_NOT_FOUND
Error message
Could not find app/routes.ts. Run this command inside a Remix app.
What it means
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.
Source
Thrown at packages/cli/src/lib/route-map.ts:288
if (typeof method !== 'string' || typeof pattern !== 'string') {
throw new Error(`Route-map loader returned an invalid route leaf for "${name}".`)
}
return {
children: [],
key,
kind,
method,
name,
pattern,
}
}
async function findRemixAppRoot(startDir: string): Promise<string> {
let appRoot = await findAppRoot(startDir, 'app/routes.ts')
if (appRoot == null) {
throw routesFileNotFound(startDir)
}
return appRoot
}
function getRouteMapWorkerPath(): string {
let currentFilePath = fileURLToPath(import.meta.url)
let extension = currentFilePath.endsWith('.ts') ? '.ts' : '.js'
return fileURLToPath(new URL(`./load-route-map-worker${extension}`, import.meta.url))
}
function createRouteMapWorkerEnv(): NodeJS.ProcessEnv {
let env = { ...process.env }
for (let key of Object.keys(env)) {
if (key.startsWith('NODE_TEST_')) {
delete env[key]View on GitHub (pinned to 9696913134)
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
Example fix
# before (in ~) remix routes # after (in project) cd my-app && remix routes
Defensive patterns
Strategy: validation
Validate before calling
import { stat } from 'node:fs/promises'
import path from 'node:path'
const findUp = async (dir: string): Promise<string | null> => {
const candidate = path.join(dir, 'app', 'routes.ts')
if (await stat(candidate).then(() => true, () => false)) return dir
const parent = path.dirname(dir)
return parent === dir ? null : findUp(parent)
} Type guard
const isRemixAppDir = (dir: string): Promise<boolean> => stat(path.join(dir, 'app', 'routes.ts')).then(() => true, () => false)
Try / catch
catch (error) {
if (error instanceof Error && error.code === 'RMX_ROUTES_FILE_NOT_FOUND') {
// prompt for the project directory
}
throw error
} Prevention
- Run Remix CLI commands from the app root
- Keep app/routes.ts at the conventional location
When it happens
Trigger: 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.
Common situations: cd'd into the wrong folder; scaffolding layout that puts the app in a nested workspace; deleted or renamed app/routes.ts.
Related errors
- hmr must be provided
- hmr requires watch mode
- Missing app/routes.ts path.
- Route module ${routesFile} must export a named "routes" valu
- RMX_ROUTE_MAP_LOADER_FAILED
AI-assisted analysis of remix-run/remix@9696913134 (2026-08-27).
Data as JSON: /api/errors/d7ea003b8bcfd2d2.
Report an issue: GitHub.