remix-run/react-router · info · Error

Exiting to avoid overwriting files

Error message

Exiting to avoid overwriting files

What it means

Thrown in copyTempDirToAppDirStep() in interactive mode after the user was prompted to confirm overwriting colliding files and answered 'no' (overwrite === false). This is an intentional, user-initiated abort — the CLI respects the user's choice not to overwrite existing files and exits cleanly.

Source

Thrown at packages/create-react-router/index.ts:415

      if (ctx.debug) {
        debug(`Colliding files:${getFileList("          ")}`);
      }

      let { overwrite } = await ctx.prompt({
        name: "overwrite",
        type: "confirm",
        label: title("overwrite"),
        message:
          `Your project directory contains files that will be overwritten by\n` +
          `             this template (you can force with \`--overwrite\`)\n\n` +
          `             Files that would be overwritten:` +
          `${getFileList("               ")}\n\n` +
          `             Do you wish to continue?\n` +
          `             `,
        initial: false,
      });
      if (!overwrite) {
        throw new Error("Exiting to avoid overwriting files");
      }
    }
  }

  await cp(ctx.tempDir, ctx.cwd, {
    filter(src) {
      // We never copy .git/ or node_modules/ directories since it's highly
      // unlikely we want them copied - and because templates are primarily
      // being pulled from git tarballs which won't have .git/ and shouldn't
      // have node_modules/
      let file = stripDirectoryFromPath(ctx.tempDir, src);
      let isIgnored = IGNORED_TEMPLATE_DIRECTORIES.includes(file);
      if (isIgnored) {
        if (ctx.debug) {
          debug(`Skipping copy of ${file} directory from template`);
        }
        return false;
      }

View on GitHub (pinned to 1fd704a7da)

Solutions

  1. Choose a different, empty target directory and re-run.
  2. Move or remove the colliding files, then re-run.
  3. If you actually want to overwrite, answer Yes at the prompt (or pass --overwrite in advance).
  4. Back up the existing directory before re-running with --overwrite.

Example fix

// CLI interaction
// prompt: Do you wish to continue? (y/N) -> N  -> throws this error
// to proceed instead:
create-react-router ./my-app   # then answer 'y' at the prompt
# or preemptively:
create-react-router ./my-app --overwrite
Defensive patterns

Strategy: validation

Validate before calling

// For scripted interactive runs, pre-flight check for collisions and pre-decide
import fs from 'node:fs';
function hasCollisions(dest: string, templateDir: string): boolean {
  // compare file lists; return true if any overlap
  return false; // implement per your template listing
}
// If you intend to overwrite, pass --overwrite; otherwise pick an empty dir.

Prevention

When it happens

Trigger: Interactive run where the destination contains files, the prompt 'Do you wish to continue?' appears, and the user answers No (default initial is false).

Common situations: User pointed at the wrong directory, saw the collision list, and chose to back out; user realised they would lose local changes; accidental rerun that the user aborts.

Related errors


AI-assisted analysis of remix-run/react-router@1fd704a7da (2026-08-12). Data as JSON: /api/errors/bbb15fec95b51d08. Report an issue: GitHub.