node.js modify text file code example
Example 1: how to right plain text format file in node js
var fs = require('fs')
var logger = fs.createWriteStream('log.txt', {
flags: 'a' // 'a' means appending (old data will be preserved)
})
logger.write('some data') // append string to your file
logger.write('more data') // again
logger.write('and more') // again
Example 2: fs create or edit file
//Edit file or creates if doesnt exist
const fs = require('fs');
fs.appendFile(‘<fileName>’,<content>,callbackFunction)