在Node.js erros中生成UUID V5,没有任何信息?
我正在使用此NPM软件包:
https://wwwww.npmjs.coms.com/package/package/package/package/uuid
我想赋予V5 UUID。
我可以通过需要模块来生成V4没有问题:
const { v4: uuidv4 } = require('uuid');
然后运行:
console.log(`uuidv4: ${uuidv4()}`);
因此,我尝试生成一个v5:
const { v5: uuidV5 } = require('uuid');
const MY_NAMESPACE = 'f709b20b-3353-4c32-8df9-66bc48e91ea9';
var v5uuid = uuidV5('hello', MY_NAMESPACE);
console.log(`userUUID: ${v5uuid}`);
但是,该应用程序可以行var v5uuid = uuidv5('Hello'hello',my_namespace); 然后直接遇到捕获错误。在变量错误中说:
'uuidv5不是函数'
运行npm ls uuid
:
├─┬ [email protected]
│ └─┬ [email protected]
│ └─┬ [email protected]
│ └── [email protected]
├─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected]
└── [email protected]
我在做什么错?
I am using this npm package:
https://www.npmjs.com/package/uuid
I want to egenrate a v5 uuid.
I can generate a v4 no problem by requiring the module:
const { v4: uuidv4 } = require('uuid');
and then running:
console.log(`uuidv4: ${uuidv4()}`);
So then I try to generate a v5:
const { v5: uuidV5 } = require('uuid');
const MY_NAMESPACE = 'f709b20b-3353-4c32-8df9-66bc48e91ea9';
var v5uuid = uuidV5('hello', MY_NAMESPACE);
console.log(`userUUID: ${v5uuid}`);
However, the app gets to line var v5uuid = uuidV5('hello', MY_NAMESPACE);
and then goes straight to the catch error. In the variables error says:
'uuidV5 is not a function'
running npm ls uuid
:
├─┬ [email protected]
│ └─┬ [email protected]
│ └─┬ [email protected]
│ └── [email protected]
├─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected]
└── [email protected]
What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
下面的解决方案对我有用!
如果您使用package.json,请添加以下
。
内容
节点索引
Below solution worked for me!
If your using package.json, add the following to package.json
Now use can use
import
with node jsCheck your output using
node index.js