簡體   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