Files
Andrea Bianchi e51e774ef8 exceptions
2026-05-05 19:50:18 +09:00

12 lines
358 B
JavaScript

// read the file and print the content
const fs = require('fs');
const path = require('path');
const data = fs.readFileSync(path.join(__dirname, 'data.json'), 'utf8');
console.log(data);
// Fix this
// Read a file that does not exist. This will throw an error.
const wrong = fs.readFileSync(path.join(__dirname, 'wrong.json'), 'utf8');
console.log(wrong);