Attempting to generate a UUID with the package uuid using these steps:
npm i -S uuid @types/uuid
import { v5 } from 'uuid';
const MY_NAMESPACE = '1b671a64-40d5-491e-99b0-da01ff1f3341';
console.log(v5('Hello, World!', MY_NAMESPACE));
When I run that I get:
TypeError: uuid_1.v5 is not a function
at Object.<anonymous> (/home/ole/slice/test.ts:3:13)
at Module._compile (internal/modules/cjs/loader.js:654:30)
Thoughts?
DefinitelyTyped is wrong: the uuid
module does not export v5
. Your import should be:
import v5 = require('uuid/v5');
Or if you have esModuleInterop
enabled, you can use:
import v5 from 'uuid/v5';