Node.js provides the fs
(File System) module to interact with the file system. You can read a file asynchronously using fs.readFile()
. Example:
const fs = require('fs');
fs.readFile('example.txt', 'utf8', (err, data) => {
if (err) {
console.error(err);
return;
}
console.log(data);
});