Simple Module which replaces fs.exists
const { exists, existsAsync } = require('enoent')
// Callback
exists('RANDOMFILE.txt', (result) => {
console.log('RANDOMFILE.txt', result)
})
// Promisified
const result = await existsAsync('RANDOMFILE.txt')
console.log('RANDOMFILE.txt', result)
Put this where you normally would import fs
const fs = require('fs')
fs.exists = require('enoent').exists
And you can use
fs.exists('myfile.txt', (result) => {
console.log(result)
})