node-dir icon indicating copy to clipboard operation
node-dir copied to clipboard

TypeError: Cannot read property 'files' of undefined

Open raghuram-periaswamy opened this issue 7 years ago • 3 comments

dir.files (recursively) throws an error if any one of the directories is empty.

stack trace:

node-dir/lib/paths.js:92
                results.files = results.files.concat(res.files);

raghuram-periaswamy avatar Oct 03 '17 09:10 raghuram-periaswamy

This is still an issue on the latest version

Version:

Screen Shot 2019-05-29 at 4 42 10 PM

Code:

Screen Shot 2019-05-29 at 4 44 07 PM

Error:

Screen Shot 2019-05-29 at 4 43 02 PM

blackarctic avatar May 29 '19 21:05 blackarctic

I just confirmed that 0.1.17 still has this behavior.

Is this a problem that is likely to be fixed at some point? If not, does anyone else have any solutions or alternate libraries to use?

eggplantzzz avatar Sep 25 '19 20:09 eggplantzzz

What I've found is while dir.files(options.projectPath, { sync: true }) fails for me as described above, dir.files(options.projectPath, (error, files) => { ... }) works fine (although is not very convenient as it doesn't even return a promise, so one has to make their way around. It's a pity that such a popular library has such an annoying and long-standing bug.

YakovL avatar Feb 05 '23 16:02 YakovL