1'use strict'
2
3const fs = require('fs');
4
5let fileContent = 'I can write';
6fs.writeFileSync('message.txt', fileContent);
1<script>
2// Requiring fs module in which
3// writeFile function is defined.
4const fs = require('fs')
5
6// Data which will write in a file.
7let data = "Learning how to write in a file."
8
9// Write data in 'Output.txt' .
10fs.writeFile('Output.txt', data, (err) => {
11
12 // In case of a error throw err.
13 if (err) throw err;
14})
15</script>