diff --git a/jsondb.js b/jsondb.js index 02f8d03..24b45ab 100644 --- a/jsondb.js +++ b/jsondb.js @@ -21,7 +21,7 @@ module.exports = function(name){ this.init = function(){ fs.readFile(this.file, (err, data) => { - if (err.errno==-2 && err.code == "ENOENT"){ + if (err && err.errno==-2 && err.code == "ENOENT"){ this.set(db); return; }else if (err) throw err;