https://github.com/leizhenpeng/nanoid-cjs
📦 latest nanoid, but support cjs for nodejs
https://github.com/leizhenpeng/nanoid-cjs
cjs nanoid nodejs
Last synced: about 1 year ago
JSON representation
📦 latest nanoid, but support cjs for nodejs
- Host: GitHub
- URL: https://github.com/leizhenpeng/nanoid-cjs
- Owner: Leizhenpeng
- License: mit
- Created: 2024-07-18T06:09:46.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-12-10T11:24:58.000Z (over 1 year ago)
- Last Synced: 2025-05-04T20:47:24.407Z (about 1 year ago)
- Topics: cjs, nanoid, nodejs
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/nanoid-cjs
- Size: 216 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# nanoid-cjs
[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]
[![bundle][bundle-src]][bundle-href]
[![JSDocs][jsdocs-src]][jsdocs-href]
[![License][license-src]][license-href]
> Latest nanoid, but support CJS for Node.js
Nanoid made breaking changes in version 4 and [no longer supports CJS imports](https://github.com/ai/nanoid/issues/365).
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.
```javascript
import { nanoid } from 'nanoid-cjs'
model.id = nanoid() //=> "V1StGXR8_Z5jdHi6B-myT"
```
```javascript
const { nanoid } = require('nanoid-cjs');
nanoid() //=> "V1StGXR8_Z5jdHi6B-myT"
```
## License
[MIT](./LICENSE) License © 2023-PRESENT [leizhenpeng](https://github.com/leizhenpeng)
[npm-version-src]: https://img.shields.io/npm/v/nanoid-cjs?style=flat&colorA=080f12&colorB=1fa669
[npm-version-href]: https://npmjs.com/package/nanoid-cjs
[npm-downloads-src]: https://img.shields.io/npm/dm/nanoid-cjs?style=flat&colorA=080f12&colorB=1fa669
[npm-downloads-href]: https://npmjs.com/package/nanoid-cjs
[bundle-src]: https://img.shields.io/bundlephobia/minzip/nanoid-cjs?style=flat&colorA=080f12&colorB=1fa669&label=minzip
[bundle-href]: https://bundlephobia.com/result?p=nanoid-cjs
[license-src]: https://img.shields.io/github/license/leizhenpeng/nanoid-cjs.svg?style=flat&colorA=080f12&colorB=1fa669
[license-href]: https://github.com/leizhenpeng/nanoid-cjs/blob/main/LICENSE
[jsdocs-src]: https://img.shields.io/badge/jsdocs-reference-080f12?style=flat&colorA=080f12&colorB=1fa669
[jsdocs-href]: https://www.jsdocs.io/package/nanoid-cjs