{"record":{"id":"72c1bf8b985454a7","repo":"parcel-bundler/parcel","slug":"enotempty","errorCode":"ENOTEMPTY","errorMessage":"ENOTEMPTY: ${path} isn't empty","messagePattern":"ENOTEMPTY: (.+?) isn't empty","errorType":"exception","errorClass":"FSError","httpStatus":null,"severity":"error","filePath":"packages/dev/repl/src/parcel/ExtendedMemoryFS.js","lineNumber":167,"sourceCode":"\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) &&\n        (await this.readdir(filePath)).length > 0\n      ) {\n        throw new FSError('ENOTEMPTY', filePath, \"isn't empty\");\n      }\n    }\n\n    return super.rimraf(filePath);\n  }\n\n  // --------------------------------\n\n  rmdir(...args: any): any {\n    return asyncToNode(args, 3, (...p) => this._rmdir(...p));\n  }\n  mkdir(...args: any): any {\n    return asyncToNode(args, 3, (...p) => this._mkdir(...p));\n  }\n  readdir(...args: any): any {\n    return asyncToNode(args, 3, (...p) => super.readdir(...p));\n  }\n  unlink(...args: any): any {","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/parcel-bundler/parcel/blob/59484858a1a0bcbb71f74088956bb437a2db6505/packages/dev/repl/src/parcel/ExtendedMemoryFS.js#L149-L185","documentation":"ENOTEMPTY raised by `ExtendedMemoryFS._rmdir` when `rimraf`/`rmdir` is called (non-recursive) on a directory whose `readdir` returns one or more entries. Mirrors Node's `fs.rmdir` non-empty semantics.","triggerScenarios":"Calling `fs.rmdir('/a')` on a directory that still contains files or subdirectories, without `{recursive: true}`.","commonSituations":"Teardown runs before all children are removed; nested writes accumulate under the dir; ported cleanup that assumed children were already gone.","solutions":["Use `{recursive: true}` to remove the dir and its contents together.","Empty the directory (remove all children) before calling rmdir.","Restructure so cleanup happens bottom-up."],"exampleFix":"// before\nawait fs.rmdir('/a');  // still has files\n// after\nawait fs.rimraf('/a', {recursive: true});","handlingStrategy":"validation","validationCode":"async function removeDir(fs, p) {\n  if ((await fs.readdir(p)).length > 0) await fs.rimraf(p, { recursive: true });\n  else await fs.rmdir(p);\n}","typeGuard":null,"tryCatchPattern":"try { await fs.rmdir(p); }\ncatch (e) { if (e.code === 'ENOTEMPTY') await fs.rimraf(p, { recursive: true }); else throw e; }","preventionTips":["Default to `{recursive: true}` when removing trees.","Ensure children are removed before parent in custom teardown.","Treat ENOTEMPTY as 'remove recursively'."],"tags":["filesystem","memory-fs","rmdir","enotempty","repl"],"backgroundTag":null,"analyzedSha":"59484858a1a0bcbb71f74088956bb437a2db6505","analyzedAt":"2026-08-13T04:06:35.925Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}