To generate guid/uuid in TypeScript Node.js app, we use the uuid
module.
For instance, we write
import { v4 as uuid } from "uuid";
const id: string = uuid();
to call the uuid
function to return a uuid string.
We run
npm install uuid
npm install --save-dev @types/uuid
to install the uuid
package and save the type definition for the package as a dev dependency.