{"record":{"id":"cbc5148584eed0bb","repo":"parcel-bundler/parcel","slug":"eexist","errorCode":"EEXIST","errorMessage":"EEXIST: ${path} already exists","messagePattern":"EEXIST: (.+?) already exists","errorType":"exception","errorClass":"FSError","httpStatus":null,"severity":"error","filePath":"packages/dev/repl/src/parcel/ExtendedMemoryFS.js","lineNumber":146,"sourceCode":" */\nexport class ExtendedMemoryFS extends MemoryFS {\n  openFDs: Map<number, {|filePath: FilePath, file: File, position: number|}> =\n    new Map();\n  nextFD: number = 1;\n\n  // eslint-disable-next-line\n  async _mkdir(\n    dir: FilePath,\n    options: {recursive?: boolean, ...} = {},\n  ): Promise<void> {\n    let {recursive = false} = options;\n\n    if (!recursive) {\n      if (!this.dirs.has(path.dirname(dir))) {\n        throw new FSError('ENOENT', path.dirname(dir), 'is not a directory');\n      }\n      if (this.dirs.has(dir)) {\n        throw new FSError('EEXIST', dir, 'already exists');\n      }\n    }\n\n    return super.mkdirp(dir);\n  }\n\n  async _rmdir(\n    filePath: FilePath,\n    options: {recursive?: boolean, ...} = {},\n  ): Promise<void> {\n    let {recursive = false} = options;\n\n    if (!recursive) {\n      if (!this.dirs.has(filePath) && !this.files.has(filePath)) {\n        throw new FSError('ENOENT', filePath, 'is not a directory');\n      }\n      if (\n        this.dirs.has(filePath) &&","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/parcel-bundler/parcel/blob/59484858a1a0bcbb71f74088956bb437a2db6505/packages/dev/repl/src/parcel/ExtendedMemoryFS.js#L128-L164","documentation":"EEXIST raised by `ExtendedMemoryFS._mkdir` when `mkdir` is called (non-recursive) on a path that is already a directory in the in-memory FS. Mirrors Node's `fs.mkdir` collision semantics.","triggerScenarios":"Calling `fs.mkdir('/a')` when `/a` already exists as a directory, without `{recursive: true}`.","commonSituations":"Code that unconditionally creates a dir on every run; ported scripts that ignore EEXIST; double initialization of the same path.","solutions":["Check `fs.existsSync(dir)` (or `statSync`) before mkdir.","Use `{recursive: true}` which is idempotent for existing dirs.","Catch EEXIST specifically and treat as success when appropriate."],"exampleFix":"// before\nawait fs.mkdir('/a');\n// after\nawait fs.mkdir('/a', {recursive: true});","handlingStrategy":"validation","validationCode":"async function ensureDir(fs, dir) {\n  if (await fs.exists(dir)) return;\n  await fs.mkdir(dir, { recursive: true });\n}","typeGuard":null,"tryCatchPattern":"try { await fs.mkdir(dir); }\ncatch (e) { if (e.code !== 'EEXIST') throw e; }","preventionTips":["Use `{recursive: true}` for idempotent creation.","Existence-check before mkdir.","Swallow EEXIST deliberately in setup code."],"tags":["filesystem","memory-fs","mkdir","eexist","repl"],"backgroundTag":null,"analyzedSha":"59484858a1a0bcbb71f74088956bb437a2db6505","analyzedAt":"2026-08-13T04:06:35.925Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}