I am fairly new to NodeJS, I am trying to read all files in a given dir and then print out the results line by line using the code below
var fs=require('fs'),fsf = require('fs'),lazy = require('lazy'); var fr; var dir = '/path/to/dir'; fs.readdir(dir,function(err,files){ if (err) throw err; files.forEach(function(file){ console.log(file); fr = fsf.createReadStream(file); //console.log(fr); new lazy(fr).lines.forEach(function(line){ console.log(line.toString()); }); }); I am getting the following error
Cannot call method 'toString' of undefined Any pointers will be really appreciated!
console.log,if (line)see it works or notENOENTso I changed yourcreateReadStream(file) to createReadStream(dir+'/'+file). This could also a problem.