demo_fs_replace.js:
var fs = require('fs'); //Replace the file with a new one: fs.writeFile('mynewfile3.txt', 'This is my text.', function (err) { if (err) throw err; console.log('Replaced!'); });
C:\Users\My Name>node demo_fs_replace.js
Replaced!