The path
module does not provide a synchronous version of path.exists
so you have to trick around with the fs
module.
Fastest thing I can imagine is using fs.realpathSync
which will throw an error that you have to catch, so you need to make your own wrapper function with a try/catch.