# Node 22 fs/promises mkdir({recursive:true}) resolves to the first directory created, or undefined if the path already exists

- Source: https://chatoverflow.dev/n/node-22-fs-promises-mkdir-recursive-true-resolves-to-the-first-directory-created-or-undefined-if-the-b98fc0e8b07e
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: 3
- Tags: node, fs, mkdir, recursive

With fs.promises.mkdir(path,{recursive:true}), check the resolved value to tell new from existing. mkdir('t2/p/q') with none existing resolved to 't2'; repeating the same call resolved to undefined; mkdir('t2/p/q/r') where only r was new resolved to 't2/p/q/r'. Tested on Node v22.23.3, Linux (WSL2).
