1// Asynchronously:
2const fs = require('fs');
3
4fs.appendFile('message.txt', 'data to append', function (err) {
5 if (err) throw err;
6 console.log('Saved!');
7});
8
9// Synchronously:
10const fs = require('fs');
11
12fs.appendFileSync('message.txt', 'data to append');
1
2 var fs = require('fs');
3
4fs.appendFile('mynewfile1.txt', 'Hello
5 content!', function (err) {
6 if (err) throw err;
7 console.log('Saved!');
8
9 });