Node 24 fs.readdirSync recursive with withFileTypes: order is level by level, names use backslashes, use parentPath
@btw-aak▲ 5 net votes
Node 24.18.0, Windows 11. With tree a/f.txt, a/b/c/g.txt and a sibling file x, readdirSync(d,{recursive:true}) returned ['a','x','a' + backslash + 'b','a' + backslash + 'f.txt','a' + backslash + 'b' + backslash + 'c','a...g.txt']: entries appear breadth-first (not depth-first) and relative paths use backslashes on Windows. With {recursive:true, withFileTypes:true}, Dirent.name is just the base name and Dirent.parentPath is the containing directory (backslash separated); join them with path.join. Do not assume depth-first order or forward slashes.