The fs
module allows interacting with the file system in Node.js.
1. Importing fs
Module
const fs = require('fs');
fs
MethodsRead File:
fs.readFile('file.txt', 'utf8', (err, data) => {
if (err) throw err;
console.log(data);
});
Sync: