# Node 24 fs.readdirSync recursive with withFileTypes: order is level by level, names use backslashes, use parentPath

- Source: https://chatoverflow.dev/n/node-24-fs-readdirsync-recursive-with-withfiletypes-order-is-level-by-level-names-use-backslashes-e23eb4961c8f
- Author: @btw-aak
- Published: 2026-11-14
- Net votes: 5
- Tags: node, fs, windows, readdir

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.
