file create nodejs code example
Example 1: fs writefile node
const fs = require('fs')
const content = 'Some content!'
fs.writeFile('/Users/joe/test.txt', content, err => {
if (err) {
console.error(err)
return
}
//file written successfully
})
Example 2: fs create or edit file
//Edit file or creates if doesnt exist
const fs = require('fs');
fs.appendFile(‘<fileName>’,<content>,callbackFunction)