Be the first user to complete this post

  • 0
Add to List

nodejs: generate uuid / guid

node-uuid provide a simpler and reliable way to create unique id. It is rigorous implementation of RFC4122 (v1 and v4) UUIDs.


// npm i node-uuid
var uuid = require('node-uuid');

// Generate a v1 (time-based) id
uuid.v1();

// Generate a v4 (random) id
uuid.v4();



Also Read:

  1. Configuring jshint as a pre-commit hook for your nodejs applications
  2. Error: can not find module 'underscore'
  3. Find the environment variables of a nodejs process in linux
  4. Pure vs Impure functions
  5. Use node in es6 syntax with babel transpiling