read from file fs node js code example
Example 1: javascript fs read
fs.readFile('/etc/passwd', (err, data) => {
if (err) throw err;
console.log(data);
});
Example 2: node read file sync
// macOS, Linux, and Windows
fs.readFileSync('<directory>');
// => [Error: EISDIR: illegal operation on a directory, read <directory>]
// FreeBSD
fs.readFileSync('<directory>'); // => <data>