Writing a file synchronously using fs.writeFileSync
method of fs
module
of node.js
//Name of the file : writefile-sync.js
//Writing a File synchronously using nodejs
var fs = require('fs');
var content = "We are writing this file synchronously using node.js";
fs.writeFileSync('content.txt', content);
console.log("File Written Successfully");
>node writefile-sync.js
File Written Successfully