npm file system doc code example
Example 1: fs writefile node
const fs = require('fs')
const content = 'Some content!'
fs.writeFile('/Users/joe/test.txt', content, err => {
if (err) {
console.error(err)
return
}
//file written successfully
})
Example 2: fs.readfile
fs.readFile('filename', function read(err, data) {
if (err) {
throw err;
}
var content = data;
console.log(content);
});