>npm init
Asha Wilma Riya
//read-file.js const fs = require('fs'), path = 'data/names.txt', prn = (obj) => console.log(obj.toString()); const callbackFct = (err, fileContents) => { if (err) throw err; prn('File Contents:'); prn(fileContents); } fs.readFile(path, callbackFct);
>node read-file File Contents: Asha Wilma Riya
//read-file-with-error.js const fs = require('fs'), path = 'data/BAD.txt', prn = (obj) => console.log(obj.toString()); const callbackFct = (err, fileContents) => { if (err) throw err; prn('File Contents:'); prn(fileContents); } fs.readFile(path, callbackFct);