How to create appending writeStream in Node.js


Current documentation here doesn’t seem to mention any parameters governing the stream’s behaviour with regards to whether file is re-created every time or just gets data appended.

Is there a way to create a writeStream which appends the data?

Problem courtesy of: Art


There is a createWriteStream method right below it.

fs.createWriteStream(path, [options]) Returns a new WriteStream object (See Writable Stream).
options is an object with the following defaults:
{ 'flags': 'w'
, 'encoding': null
, 'mode': 0666

Solution courtesy of: Corey Hart

View additional discussion.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.