{"record":{"id":"90523c2168ad8e91","repo":"parcel-bundler/parcel","slug":"file-or-directory-at-packagepath-already-exists","errorCode":null,"errorMessage":"File or directory at ${packagePath} already exists","messagePattern":"File or directory at (.+?) already exists","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/utils/create-react-app/src/cli.js","lineNumber":46,"sourceCode":"  .name('create-react-app')\n  .version(version)\n  .arguments('<path-to-new-app>')\n  .action(command => {\n    run(command).catch(reason => {\n      // eslint-disable-next-line no-console\n      console.error(chalk`${emoji.error} {red ${reason.message}}`);\n      process.exit(1);\n    });\n  })\n  .parse();\n\nasync function run(packagePath: string) {\n  log(\n    chalk`${emoji.progress} {green Creating Parcel app at}`,\n    chalk.bold.underline(packagePath),\n  );\n  if (await fsExists(packagePath)) {\n    throw new Error(`File or directory at ${packagePath} already exists`);\n  }\n\n  let tempPath = tempy.directory();\n  try {\n    await createApp(path.basename(packagePath), tempPath);\n  } catch (e) {\n    await rimraf(tempPath);\n    throw e;\n  }\n\n  await fs.promises.rename(tempPath, packagePath);\n\n  log(\n    chalk`{green ${emoji.success} Successfully created a new Parcel app at {bold.underline ${packagePath}}.}`,\n  );\n  log(\n    chalk`${\n      emoji.info","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/parcel-bundler/parcel/blob/59484858a1a0bcbb71f74088956bb437a2db6505/packages/utils/create-react-app/src/cli.js#L28-L64","documentation":"Thrown by @parcel/create-react-app's CLI (run function) when the target packagePath already exists on disk (fsExists returns true). It is a plain Error (not a ThrowableDiagnostic), surfaced via chalk red in the CLI's catch handler, then process.exit(1).","triggerScenarios":"User runs the create-app CLI with a destination path that already contains a file or directory.","commonSituations":"Re-running the scaffold command after a partial/previous run, pointing at an existing project folder, or a leftover empty directory from a failed attempt.","solutions":["Pick a different, non-existent packagePath.","Delete or move the existing file/directory: `rm -rf <path>`.","If the previous run was interrupted, remove the partial scaffold and retry."],"exampleFix":"// before\n$ npx create-react-app my-app   # my-app exists\n// after\n$ rm -rf my-app && npx create-react-app my-app","handlingStrategy":"validation","validationCode":"const fs = require('fs').promises;\nasync function assertTargetFree(p) {\n  try { await fs.access(p); throw new Error('Path exists: ' + p); } catch (e) { if (e.code !== 'ENOENT') throw e; }\n}","typeGuard":null,"tryCatchPattern":"try {\n  await run(packagePath);\n} catch (e) {\n  if (/already exists/.test(e.message)) console.error('Choose a fresh path or remove the existing one.');\n  throw e;\n}","preventionTips":["Check the destination path before running the scaffold CLI.","Clean up partial scaffolds from interrupted runs.","Use a unique project name per attempt."],"tags":["create-react-app","cli","filesystem","scaffold"],"backgroundTag":null,"analyzedSha":"59484858a1a0bcbb71f74088956bb437a2db6505","analyzedAt":"2026-08-13T04:06:35.925Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}