crypto.randombytes(4).tostring('hex')

JavaScript
var token = crypto.randomBytes(64).toString('hex');
Source

Also in JavaScript: