fswriteFileSync
fswriteFileSync is the synchronous counterpart to the Node.js file system write operation. It is a function in the built-in fs module that writes data to a file and blocks the event loop until the operation completes. If the target file already exists, its contents are replaced unless a different flag is specified.
The typical signature is fs.writeFileSync(file, data, options). The file parameter can be a path string, a Buffer,
Behavior and errors: The call throws an exception on failure instead of using a callback. Common errors
Usage considerations: Because it blocks the event loop, writeFileSync is best suited for startup scripts, CLI
Example: fs.writeFileSync('example.txt', 'Hello world', 'utf8'); You can also pass an options object: fs.writeFileSync('example.txt', data, { encoding: 'utf8',