繁体   English   中英

如何在 NodeJS 上使用 nanoid 模块?

[英]How to use nanoid module on NodeJS?

我知道也许这个问题很愚蠢,但我无法让nanoid在我的 NodeJS 应用程序上工作。

我已经阅读了文档。

这是我的 app.js 配置:

var nanoid = require("nanoid");
var ID = nanoid();

我收到错误消息:

TypeError: nanoid is not a function
  at Object.<anonymous> (myapp.js directory)

也许我需要在 nanoid 中导入 function 但我不知道该怎么做。 帮助将不胜感激。 谢谢。

nanoid 是模块内部的 function 试试这个

var { nanoid } = require("nanoid");
var ID = nanoid();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM