ai / nanoid

A tiny (124 bytes), secure, URL-friendly, unique string ID generator for JavaScript

Home Page:https://zelark.github.io/nano-id-cc/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Could not resolve import "crypto"

bsastregx opened this issue · comments

Hi,
I am getting the following error on a project I am using nanoid:

Error while transforming node_modules/nanoid/index.js: Could not resolve import "crypto".

I am using nanoid on a Lit-element project : https://lit.dev/

Nano ID has 2 versions: for browser and for Node.js.

Seems like your bundler didn’t change the file to browser’s version. I recommend you to ask help in your bundle’s community about using package.browser and package.exports.

Another [bad] way is to use import { nanoid } from 'nanoid/index.browser.js'

@ai Thanks!
When you say ask for help in my bundle's community, where exactly do you mean? can you provide a url?

@ai Thanks! When you say ask for help in my bundle's community, where exactly do you mean? can you provide a url?

What bundler are you using? (webpack, rollup, vite (via rollup), etc...)

I understand, now. Thanks!