Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERR_REQUIRE_ESM' const { nanoid } = require("nanoid"); #465

Closed
LeCongNam opened this issue Jan 24, 2024 · 1 comment
Closed

ERR_REQUIRE_ESM' const { nanoid } = require("nanoid"); #465

LeCongNam opened this issue Jan 24, 2024 · 1 comment

Comments

@LeCongNam
Copy link

LeCongNam commented Jan 24, 2024

i'm using nanoid@5.0.4 with nestjs
When i'm import like used website npm once error throw.
import { nanoid } from 'nanoid'
I'm downgrade version : npm install nanoid@^3.0.0 library work well. Please fix it. Why you break every think? I'm love nanoid.
Please fix prolem. Thank

@LeCongNam LeCongNam changed the title 'ERR_REQUIRE_ESM' const { nanoid } = require("nanoid"); ERR_REQUIRE_ESM' const { nanoid } = require("nanoid"); Jan 24, 2024
@ai
Copy link
Owner

ai commented Jan 24, 2024

Nano ID 4/5 works only for ESM-only app.

If you use legacy CJS, use Nano ID 3.x (you find command in docs).

We did it because supporting CJS and ESM together requires 2x code, which is not “nano”.

@ai ai closed this as completed Jan 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants