// Load the filesystem module
const fs = require('fs');
// Read file asynchronously
fs.readFile('myfile.txt', 'utf8', (err, data) => {
if (err) {
console.error('Error reading file: ' + err);
return;
}
console.log('File content: ' + data);
});
console.log('Reading file... (this runs first!)');
Reading file... (this runs first!) File content: This is the content of myfile.txt