npm install jsonwebtoken
var jwt = require('jsonwebtoken');
var auth = {
id : id,
name : 'moin',
email : 'mastermoin409@gmail.com',
}
var token = jwt.sign({ authToken: auth }, 'shhh.....', {expiresIn : 1800});
'shhh.....' is private key or secret key of your application, it is normally string
1800 is token expiry time
More about API : https://github.com/auth0/node-jsonwebtoken