writefile usando nodejs de fluxo de string

const stream = require('stream')
const fs = require('fs')

const html = "<h1> Hello Wordl </h1>

// read file from string and write file
const stream = new Stream()
stream.pipe = function (dest) {
  dest.write(html)
  return dest
}
stream.pipe(createWriteStream(resolve(process.cwd(), 'index.html'), 'utf8'))

// read file from directory and write file
fs.createReadStream('testing.html')
 .pipe(createWriteStream(resolve(process.cwd(), 'index.html'), 'utf8'))
Restu Wahyu Saputra