I search for this question in node api, stackoverflow and (ofcourse) google, and didn't find the answer...I have trouble with ReadStream in node.js: he erase all content in file, even using flag for reading. I have few large files in JSON, and I need to read data from them. Every time, when I create stream to one of them, they empty. Example:
var stream = fs.createReadStream("./somefile.json", { flags: 'r', encoding: 'utf-8' });
stream.on('data', function(d) {
// do something
});
We are using node.js 0.12.7 (yeah, it's old, like the project on which I working).