I'm trying to check if a directory exists as part of a command-line app in node.js. However, fs
doesn't seem to understand ~/
. For example, the following returns false...
> fs.existsSync('~/Documents')
false
...but this returns true...
> fs.existsSync('/Users/gtmtg/Documents')
true
...even though they're both the same thing.
Why does this happen, and is there are workaround for this? Thanks in advance!
That's because ~/
is supported by the command shell, not the file system APIs.