I am attempting to determine if a file exists. If it does not exist, I would like my code to continue so it will be created. When I use the following code, if the file exists, it prints that 'it exists'. If it does not exist, it crashes my app. Here is my code:
var checkDuplicateFile = function(){
var number = room.number.toString();
var stats = fs.statSync(number);
if(stat){
console.log('it exists');
}else{
console.log('it does not exist');
}
};