fs.readFile('filename', function read(err, data) { if (err) { throw err; } var content = data; console.log(content); });
// macOS, Linux, and Windows fs.readFileSync('<directory>'); // => [Error: EISDIR: illegal operation on a directory, read <directory>] // FreeBSD fs.readFileSync('<directory>'); // => <data>