Latest nanoid, but support CJS for Node.js
Nanoid made breaking changes in version 4 and no longer supports CJS imports.
This is a disaster for developers using older versions of Node.js, especially those working with NestJS.
Here, we use the Vercel NCC compiler to compile it, perfectly supporting CJS syntax.
import { nanoid } from 'nanoid-cjs'
model.id = nanoid() //=> "V1StGXR8_Z5jdHi6B-myT"
const { nanoid } = require('nanoid-cjs');
nanoid() //=> "V1StGXR8_Z5jdHi6B-myT"
MIT License © 2023-PRESENT leizhenpeng