1var fs = require('fs')
2fs.readFile(someFile, 'utf8', function (err,data) {
3 if (err) {
4 return console.log(err);
5 }
6 var result = data.replace(/string to be replaced/g, 'replacement');
7
8 fs.writeFile(someFile, result, 'utf8', function (err) {
9 if (err) return console.log(err);
10 });
11});