9951 explained code solutions for 126 technologies


nodejsHow to write file


const fs = require('fs');
fs.writeFile('/tmp/test.txt', 'hi!', (err, data) => {
  console.log(err);
});ctrl + c
require('fs')

library to work with file system

/tmp/test.txt

path of file to write

'hi!'

Data to write to file

console.log(err)

if err is not null, something wrong happened

fs.writeFile(

writes given data to specified file