Проверьте, является ли файл пустым JavaScript fs

if (fs.exists('myfile.txt')) {
    if (fs.read('myfile.txt').length === 0) {
        console.log("File is Empty")
    } else {
        return JSON.parse(fs.read('myfile.txt'));
    }
}
Undefined