1const fs = require('fs');
2
3fs.appendFile('message.txt', 'data to append', function (err) {
4 if (err) throw err;
5 console.log('Saved!');
6});
7
8If message.txt doesnt exist, It will gonna create that too
9
1Synchronously
2
3const fs = require('fs');
4
5fs.appendFileSync('message.txt', 'data to append');
6