file_get_contents() equivalent for Node.JS

fs.readFileSync appears to do what you're asking. From the manual:

fs.readFileSync(filename, [options])

Synchronous version of fs.readFile. Returns the contents of the filename.

If the encoding option is specified then this function returns a string. Otherwise it returns a buffer.


Nice for load some conf files on app start but its Sync !!!!

const fs = require('fs');
var contents = fs.readFileSync('inject.txt').toString();

No, there's not. Do it asynchronously: Do stuff, and when the download completes and you've buffered it all into one place, emit an event or call a callback to do the work on the whole blob.