{"record":{"id":"710cfae522ecd832","repo":"parcel-bundler/parcel","slug":"enoent-710cfa","errorCode":"ENOENT","errorMessage":"ENOENT: ${path} is not a directory","messagePattern":"ENOENT: (.+?) is not a directory","errorType":"exception","errorClass":"FSError","httpStatus":null,"severity":"error","filePath":"packages/dev/repl/src/parcel/ExtendedMemoryFS.js","lineNumber":143,"sourceCode":"\n/**\n * Can be used as a standin for the npm `require(\"fs\")` package because `MemoryFS` not API compatible.\n */\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');","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/parcel-bundler/parcel/blob/59484858a1a0bcbb71f74088956bb437a2db6505/packages/dev/repl/src/parcel/ExtendedMemoryFS.js#L125-L161","documentation":"Posix-style ENOENT raised by `ExtendedMemoryFS._mkdir` when `mkdir` is called without `recursive: true` and the parent directory does not exist in the in-memory FS. Mirrors Node's `fs.mkdir` semantics inside the REPL's MemoryFS.","triggerScenarios":"Calling `fs.mkdir('/a/b')` when `/a` is not present, without `{recursive: true}`. Common from tooling that assumes parents already exist.","commonSituations":"A packager/transformer in the REPL calls mkdir on a nested path before creating ancestors; ported Node code that relied on real node_modules structure.","solutions":["Create parent directories first, or pass `{recursive: true}`.","Use `fs.mkdirp` if available on the FS instance.","Pre-seed the memory FS with expected directory structure before the operation."],"exampleFix":"// before\nawait fs.mkdir('/a/b');\n// after\nawait fs.mkdir('/a/b', {recursive: true});","handlingStrategy":"validation","validationCode":"async function safeMkdir(fs, dir) {\n  const parent = path.dirname(dir);\n  if (!(await fs.exists(parent))) throw new Error(`missing parent ${parent}`);\n  return fs.mkdir(dir, { recursive: true });\n}","typeGuard":null,"tryCatchPattern":"try { await fs.mkdir(dir); }\ncatch (e) { if (e.code === 'ENOENT') await fs.mkdir(dir, { recursive: true }); else throw e; }","preventionTips":["Default to `{recursive: true}` for nested paths.","Pre-create expected parent directories during setup.","Centralize directory creation through a helper that always uses recursive."],"tags":["filesystem","memory-fs","mkdir","enoent","repl"],"backgroundTag":null,"analyzedSha":"59484858a1a0bcbb71f74088956bb437a2db6505","analyzedAt":"2026-08-13T04:06:35.925Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}