Join the AI Workshop and learn to build real-world apps with AI. A hands-on, practical program to level up your skills.
To write text to a file in Node.js, use fs.writeFile():
import fs from 'node:fs'
const text = 'yo'
fs.writeFile('text.txt', text, (err) => {
if (err) {
console.error(err)
}
console.log('done')
})