lerna/lerna · error · ValidationError

EEXISTS

EEXISTS

Error message

Target directory already exists "${targetDir}"

What it means

Error "Target directory already exists "${targetDir}"" thrown in lerna/lerna.

Source

Thrown at libs/commands/import/src/index.ts:105

      );
    }
    const targetDir = path.join(targetBase, externalRepoBase);

    // Compute a target directory relative to the Git root
    const gitRepoRoot = this.getWorkspaceRoot();
    const lernaRootRelativeToGitRoot = path.relative(gitRepoRoot, this.project.rootPath);
    this.targetDirRelativeToGitRoot = path.join(lernaRootRelativeToGitRoot, targetDir);

    //if the target directory is not in the Git root
    if (this.targetDirRelativeToGitRoot.startsWith("..")) {
      throw new ValidationError(
        "ENOTINREPO",
        `Project root ${this.project.rootPath} is not a subdirectory of git root ${gitRepoRoot}`
      );
    }

    if (fs.existsSync(path.resolve(this.project.rootPath, targetDir))) {
      throw new ValidationError("EEXISTS", `Target directory already exists "${targetDir}"`);
    }

    this.commits = this.externalExecSync("git", this.gitParamsForTargetCommits()).split("\n").reverse();
    // this.commits = this.externalExecSync("git", [
    //   "rev-list",
    //   "--no-merges",
    //   "--topo-order",
    //   "--reverse",
    //   "HEAD",
    // ]).split("\n");

    if (!this.commits.length) {
      throw new ValidationError("NOCOMMITS", `No git commits to import at "${inputPath}"`);
    }

    if (this.options.preserveCommit) {
      // Back these up since they'll change for each commit
      this.origGitEmail = this.execSync("git", ["config", "user.email"]);

View on GitHub (pinned to 35d15a1567)

When it happens

Trigger: Thrown at libs/commands/import/src/index.ts:105 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of lerna/lerna@35d15a1567 (2026-08-27). Data as JSON: /api/errors/6e7715e4bac3e7e5. Report an issue: GitHub.