Using Node.js Native API
Example
const fs = require('fs');
// Read file
fs.readFile('/path/to/file.txt', (err, data) => {
if (err) throw err;
console.log(data);
});
// Write file
fs.writeFile('/path/to/file.txt', 'Hello, world!', (err) => {
if (err) throw err;
console.log('The file has been saved!');
});
Recommended Learning Resources
Last updated