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';
I was also getting the similar problem.
Try the following and it will work.
//I use v4 so , but try .v5 if you want to
const uuid = require('uuid').v4
//now can call uuid
uuid()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With