remix-run/remix · error · CliError

RMX_TARGET_PATH_NOT_DIRECTORY

RMX_TARGET_PATH_NOT_DIRECTORY

Error message

Target path is not a directory

What it means

The path you supplied as the app target exists but is a file (or otherwise not a directory), so the CLI cannot scaffold a project there. The fix hint tells you to choose a directory path.

Source

Thrown at packages/cli/src/lib/errors.ts:137

    title: 'Route-map loader exited from a signal',
    fix: 'Check app/routes.ts for side effects or runtime issues and try again.',
  },
  routeOwnerPlanUnresolved: {
    code: 'RMX_ROUTE_OWNER_PLAN_UNRESOLVED',
    title: 'Could not resolve a route owner plan',
  },
  routesFileNotFound: {
    code: 'RMX_ROUTES_FILE_NOT_FOUND',
    title: 'Could not find app/routes.ts',
    fix: 'Run this command inside a Remix app that has app/routes.ts.',
  },
  targetDirectoryNotEmpty: {
    code: 'RMX_TARGET_DIRECTORY_NOT_EMPTY',
    title: 'Target directory is not empty',
    fix: 'Re-run with --force to continue.',
  },
  targetPathNotDirectory: {
    code: 'RMX_TARGET_PATH_NOT_DIRECTORY',
    title: 'Target path is not a directory',
    fix: 'Choose a directory path for the new app target.',
  },
  unexpectedExtraArgument: {
    code: 'RMX_UNEXPECTED_ARGUMENT',
    title: 'Unexpected extra argument',
    fix: 'Remove the extra argument or run the command with --help.',
  },
  unknownArgument: {
    code: 'RMX_UNKNOWN_ARGUMENT',
    title: 'Unknown argument',
    fix: 'Run the command with --help to see supported arguments.',
  },
  unknownCommand: {
    code: 'RMX_UNKNOWN_COMMAND',
    title: 'Unknown command',
    fix: 'Run `remix help` to see available commands.',
  },

View on GitHub (pinned to 9696913134)

Solutions

  1. Choose a new or existing directory path as the target.
  2. Remove or rename the colliding file if it was created by mistake.
  3. Check for symlinks pointing at files with `ls -l <path>`.

Example fix

# before
remix init ./notes.md

# after
remix init ./my-new-app
Defensive patterns

Strategy: validation

Validate before calling

import { stat } from 'node:fs/promises'

let s = await stat(target).catch(() => null)
if (s && !s.isDirectory()) {
  // pick a different target before running the command
}

Try / catch

try {
  await scaffold(target)
} catch (error) {
  if (error.code === 'RMX_TARGET_PATH_NOT_DIRECTORY') {
    // choose a directory path and retry
  }
}

Prevention

When it happens

Trigger: Passing a path that resolves to an existing file, a symlink to a file, or a path with a trailing filename component as the target of a create command.

Common situations: Typos like `remix init app.txt`, targets colliding with existing files (package.json, README), or symlink confusion in workspaces.

Related errors


AI-assisted analysis of remix-run/remix@9696913134 (2026-08-27). Data as JSON: /api/errors/b714adb25d51dbc7. Report an issue: GitHub.