{"record":{"id":"6e7715e4bac3e7e5","repo":"lerna/lerna","slug":"eexists","errorCode":"EEXISTS","errorMessage":"Target directory already exists \"${targetDir}\"","messagePattern":"Target directory already exists \"(.+?)\"","errorType":"validation","errorClass":"ValidationError","httpStatus":null,"severity":"error","filePath":"libs/commands/import/src/index.ts","lineNumber":105,"sourceCode":"      );\n    }\n    const targetDir = path.join(targetBase, externalRepoBase);\n\n    // Compute a target directory relative to the Git root\n    const gitRepoRoot = this.getWorkspaceRoot();\n    const lernaRootRelativeToGitRoot = path.relative(gitRepoRoot, this.project.rootPath);\n    this.targetDirRelativeToGitRoot = path.join(lernaRootRelativeToGitRoot, targetDir);\n\n    //if the target directory is not in the Git root\n    if (this.targetDirRelativeToGitRoot.startsWith(\"..\")) {\n      throw new ValidationError(\n        \"ENOTINREPO\",\n        `Project root ${this.project.rootPath} is not a subdirectory of git root ${gitRepoRoot}`\n      );\n    }\n\n    if (fs.existsSync(path.resolve(this.project.rootPath, targetDir))) {\n      throw new ValidationError(\"EEXISTS\", `Target directory already exists \"${targetDir}\"`);\n    }\n\n    this.commits = this.externalExecSync(\"git\", this.gitParamsForTargetCommits()).split(\"\\n\").reverse();\n    // this.commits = this.externalExecSync(\"git\", [\n    //   \"rev-list\",\n    //   \"--no-merges\",\n    //   \"--topo-order\",\n    //   \"--reverse\",\n    //   \"HEAD\",\n    // ]).split(\"\\n\");\n\n    if (!this.commits.length) {\n      throw new ValidationError(\"NOCOMMITS\", `No git commits to import at \"${inputPath}\"`);\n    }\n\n    if (this.options.preserveCommit) {\n      // Back these up since they'll change for each commit\n      this.origGitEmail = this.execSync(\"git\", [\"config\", \"user.email\"]);","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/lerna/lerna/blob/35d15a1567932be97759f512d8b8033dad72b411/libs/commands/import/src/index.ts#L87-L123","documentation":"Error \"Target directory already exists \"${targetDir}\"\" thrown in lerna/lerna.","triggerScenarios":"Thrown at libs/commands/import/src/index.ts:105 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"35d15a1567932be97759f512d8b8033dad72b411","analyzedAt":"2026-08-27T05:01:00.632Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}