{"record":{"id":"bbb15fec95b51d08","repo":"remix-run/react-router","slug":"exiting-to-avoid-overwriting-files","errorCode":null,"errorMessage":"Exiting to avoid overwriting files","messagePattern":"Exiting to avoid overwriting files","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"info","filePath":"packages/create-react-router/index.ts","lineNumber":415,"sourceCode":"      if (ctx.debug) {\n        debug(`Colliding files:${getFileList(\"          \")}`);\n      }\n\n      let { overwrite } = await ctx.prompt({\n        name: \"overwrite\",\n        type: \"confirm\",\n        label: title(\"overwrite\"),\n        message:\n          `Your project directory contains files that will be overwritten by\\n` +\n          `             this template (you can force with \\`--overwrite\\`)\\n\\n` +\n          `             Files that would be overwritten:` +\n          `${getFileList(\"               \")}\\n\\n` +\n          `             Do you wish to continue?\\n` +\n          `             `,\n        initial: false,\n      });\n      if (!overwrite) {\n        throw new Error(\"Exiting to avoid overwriting files\");\n      }\n    }\n  }\n\n  await cp(ctx.tempDir, ctx.cwd, {\n    filter(src) {\n      // We never copy .git/ or node_modules/ directories since it's highly\n      // unlikely we want them copied - and because templates are primarily\n      // being pulled from git tarballs which won't have .git/ and shouldn't\n      // have node_modules/\n      let file = stripDirectoryFromPath(ctx.tempDir, src);\n      let isIgnored = IGNORED_TEMPLATE_DIRECTORIES.includes(file);\n      if (isIgnored) {\n        if (ctx.debug) {\n          debug(`Skipping copy of ${file} directory from template`);\n        }\n        return false;\n      }","sourceCodeStart":397,"sourceCodeEnd":433,"githubUrl":"https://github.com/remix-run/react-router/blob/1fd704a7dabcbe3ae09d7387b460e6acaba30ec1/packages/create-react-router/index.ts#L397-L433","documentation":"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.","triggerScenarios":"Interactive run where the destination contains files, the prompt 'Do you wish to continue?' appears, and the user answers No (default initial is false).","commonSituations":"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.","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."],"exampleFix":"// CLI interaction\n// prompt: Do you wish to continue? (y/N) -> N  -> throws this error\n// to proceed instead:\ncreate-react-router ./my-app   # then answer 'y' at the prompt\n# or preemptively:\ncreate-react-router ./my-app --overwrite","handlingStrategy":"validation","validationCode":"// For scripted interactive runs, pre-flight check for collisions and pre-decide\nimport fs from 'node:fs';\nfunction hasCollisions(dest: string, templateDir: string): boolean {\n  // compare file lists; return true if any overlap\n  return false; // implement per your template listing\n}\n// If you intend to overwrite, pass --overwrite; otherwise pick an empty dir.","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["cli","filesystem","overwrite","interactive","user-abort","create-react-router"],"backgroundTag":null,"analyzedSha":"1fd704a7dabcbe3ae09d7387b460e6acaba30ec1","analyzedAt":"2026-08-12T13:54:57.804Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}