wscfan-nanoid
v1.0.6
Published
A Nuxt2 and Node.js compatible wrapper for nanoid with ESM support
Downloads
14
Maintainers
Readme
wscfan-nanoid
A Nuxt2 + Server-Side compatible wrapper for nanoid that solves ESM/CJS compatibility issues.
✨ 特性
- ✅ 完全兼容 Nuxt2 项目
- ✅ 支持 Node.js 服务端引入(解决 ESM require 报错)
- ✅ 使用
dynamic import()兼容 nanoid@5+ - ✅ 同时支持
require和import
📦 安装
npm install wscfan-nanoid --save🚀 使用示例(服务端)
// 必须在 async 函数内使用
const { nanoid } = require('wscfan-nanoid');
async function generateId() {
const id = await nanoid(); // 注意:必须用 await!
console.log(id);
}