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
- Choose a different, empty target directory and re-run.
- Move or remove the colliding files, then re-run.
- If you actually want to overwrite, answer Yes at the prompt (or pass --overwrite in advance).
- 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
- Read the collision list in the prompt carefully before answering.
- Pre-pass --overwrite only when you have a backup.
- Target fresh directories to avoid the prompt entirely.
- Treat the default 'No' as a safe abort and choose another directory.
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
- File collisions detected in a non-interactive environment
- The provided template is not a valid local directory or tarb
- There was a problem extracting the file from the provided te
- No project directory provided
- "${template}" is an invalid template. Run "create-react-rout
AI-assisted analysis of remix-run/react-router@1fd704a7da (2026-08-12).
Data as JSON: /api/errors/bbb15fec95b51d08.
Report an issue: GitHub.