I noticed that the official node documentation says something startling about fs.exists:
\"fs.exists() is an anachronism and exists only
I was searching for a solution to this issue and found that fs.exists and fs.existsSync was deprecated. This seems to work well in my senario
fs.readFile(filename, 'utf8', function(err,data){
// the err variable substitutes for the fs.exists callback function variable
if (!err){
// do what you planned with the file
console.log(data)
}else{
// handle the non-existence of the file
console.log('File does not exist!');
}
});