According to the documentation node.js fs.exists() will be deprecated. Their reasoning:
fs.exists() is an anachronism and exists only for historical reasons.
Here is an example using fs.stat, but handling errors correctly as well:
fs.stat
async function fileExists(filename) { try { await fs.promises.stat(filename); return true; } catch (err) { if (err.code === 'ENOENT') { return false; } else { throw err; } } }