var fs = require('fs');
fs.readFile('TestFile.txt', function (err, data) {
if (err) throw err;
console.log(data);
});
//TestFile.txt This is test file to test fs module of Node.js
According to the documentation :
If no encoding is specified (using options.encoding), the data is returned as a
<Buffer>object. Otherwise, the data will be a string.
Solution : add an encoding (and read the doc! :)
fs.readFile('TestFile.txt', { encoding : 'utf8' } , function()...
By converting data to String(data) you will get text