Let me know if this is what you are looking for.
// On top of your script, or whatever var crypto = require('crypto'); // wherever you want function randomObjectId() { return crypto.createHash('md5').update(Math.random().toString()).digest('hex').substring(0, 24); }
With any latest version of cryptography, you can use the abbreviation:
crypto.randomBytes(12).toString('hex')
source share