parcel-bundler/parcel · error · Error

File or directory at ${packagePath} already exists

Error message

File or directory at ${packagePath} already exists

What it means

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).

Source

Thrown at packages/utils/create-react-app/src/cli.js:46

  .name('create-react-app')
  .version(version)
  .arguments('<path-to-new-app>')
  .action(command => {
    run(command).catch(reason => {
      // eslint-disable-next-line no-console
      console.error(chalk`${emoji.error} {red ${reason.message}}`);
      process.exit(1);
    });
  })
  .parse();

async function run(packagePath: string) {
  log(
    chalk`${emoji.progress} {green Creating Parcel app at}`,
    chalk.bold.underline(packagePath),
  );
  if (await fsExists(packagePath)) {
    throw new Error(`File or directory at ${packagePath} already exists`);
  }

  let tempPath = tempy.directory();
  try {
    await createApp(path.basename(packagePath), tempPath);
  } catch (e) {
    await rimraf(tempPath);
    throw e;
  }

  await fs.promises.rename(tempPath, packagePath);

  log(
    chalk`{green ${emoji.success} Successfully created a new Parcel app at {bold.underline ${packagePath}}.}`,
  );
  log(
    chalk`${
      emoji.info

View on GitHub (pinned to 59484858a1)

Solutions

  1. Pick a different, non-existent packagePath.
  2. Delete or move the existing file/directory: `rm -rf <path>`.
  3. If the previous run was interrupted, remove the partial scaffold and retry.

Example fix

// before
$ npx create-react-app my-app   # my-app exists
// after
$ rm -rf my-app && npx create-react-app my-app
Defensive patterns

Strategy: validation

Validate before calling

const fs = require('fs').promises;
async function assertTargetFree(p) {
  try { await fs.access(p); throw new Error('Path exists: ' + p); } catch (e) { if (e.code !== 'ENOENT') throw e; }
}

Try / catch

try {
  await run(packagePath);
} catch (e) {
  if (/already exists/.test(e.message)) console.error('Choose a fresh path or remove the existing one.');
  throw e;
}

Prevention

When it happens

Trigger: User runs the create-app CLI with a destination path that already contains a file or directory.

Common situations: 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.

Related errors


AI-assisted analysis of parcel-bundler/parcel@59484858a1 (2026-08-13). Data as JSON: /api/errors/90523c2168ad8e91. Report an issue: GitHub.