Write file in node js

Write file in node 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!');
});

// You can write anything in this file by using writeFile() function

Leave a Reply