0

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).

bodzin
  • 56
  • 3
  • Reading from a file like that will not erase the contents. The culprit is most likely somewhere else in your code. – mscdex Mar 28 '16 at 14:35
  • Check this link http://stackoverflow.com/questions/30601002/createreadstream-in-node-js][1] Hope it helps – Franklin Mar 30 '16 at 13:10

0 Answers0