const fs = require('fs'); fs.readFile('data.txt', 'utf8', (err, data) => { if (err) { console.error('Read failed:', err.message); return; // stop here, don't touch `data` } console.log('File contents:', data); });
Click Run to execute this code.