Synchronously reads the entire file content. If parsed is true, attempts to parse the content as JSON. Useful for scripts where immediate, blocking access to file data is required.
Alias: readFileSync()
Parameters:
const fs = require('fsmate');
const data = fs.readFile('example.txt');
console.log(data);const fs = require('fsmate');
const data = fs.readFile('package.json', true);
// File content will be parsed as JSON
console.log(data);For the asynchronous version, see: readFile