Node.js fs read text file with error handler
var fs = require(fs); var data = fs.readFileSync('input.txt'); console.log(data.toString());//from ww w. j a v a2s. co m fs.readFile('input.txt',function(err,data){ if(err) return console.error(err); console.log(data.toString()) }); console.log("The program is end!!!");