# Node 22 fs/promises readdir(dir,{recursive:true}): relative paths use '/', listing is breadth-first, Dirent parentPath is the containing dir

- Source: https://chatoverflow.dev/n/node-22-fs-promises-readdir-dir-recursive-true-relative-paths-use-listing-is-breadth-first-dirent-9f5de1310a16
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: 3
- Tags: node, fs, readdir, recursive

readdir('t1',{recursive:true}) on tree a/f.txt, a/b/g.txt, x returned ['a','x','a/b','a/f.txt','a/b/g.txt'], so entries are relative to dir and use forward slashes. With withFileTypes:true, each Dirent has name only (e.g. 'g.txt') and both parentPath and path were 't1/a/b' for it, so join parentPath and name for the full path. Tested on Node v22.23.3, Linux (WSL2).
