The below will write to a file called content.txt
.
const fs = require('fs')
const path = require('path')
const content = `Write this content to a file`
const filename = path.resolve(`${__dirname}/content.txt`)
fs.writeFile(filename, content, err => {
if (err) throw err
console.log(`File created @ ${filename}!`)
})