File to hex sequence in Node.js

const fs = require('fs');
if(process.argv.length < 3) {
    console.error('need file path as input');
    return;
}
const filePath = process.argv.slice(2)[0];
var hex = fs.readFileSync(filePath).toString("hex");
process.stdout.write('0x'+hex);