I'm trying to use this answer to allow me to check if a given file path is a directory, however I get the following error:
fs.js:679
return binding.lstat(pathModule._makeLong(path));
^
Error: ENOENT, no such file or directory '.DS_Store'
at Object.fs.lstatSync (fs.js:679:18)
I figured that maybe it couldn't handle hidden files well, so, after failing to find a more elegant solution, I checked if the first character in the file name was a '.'. However, the program then crashed on another file:
fs.js:679
return binding.lstat(pathModule._makeLong(path));
^
Error: ENOENT, no such file or directory 'README.md'
at Object.fs.lstatSync (fs.js:679:18)
Why does fs.lstatSync()
seem to error for such common files, and how can I make it work (correctly evaluate if the given path is a directory)?