create a file with node js code example
Example 1: fs create or edit file
//Edit file or creates if doesnt exist
const fs = require('fs');
fs.appendFile(‘<fileName>’,<content>,callbackFunction)
Example 2: javascript write to file
<script>
// Requiring fs module in which
// writeFile function is defined.
const fs = require('fs')
// Data which will write in a file.
let data = "Learning how to write in a file."
// Write data in 'Output.txt' .
fs.writeFile('Output.txt', data, (err) => {
// In case of a error throw err.
if (err) throw err;
})
</script>