nodejs import instead of require
import fs from 'fs/promises';
import path from 'path';
async function readAndPrintFile(filePath) {
try {
const content = await fs.readFile(filePath, 'utf-8');
console.log(content);
} catch (error) {
console.error(`Error reading the file: ${error.message}`);
}
}
const filePath = path.join(__dirname, 'example.txt');
readAndPrintFile(filePath);