adamhalasz / uniqid

Unique ID Generator
https://adamhalasz.com
617 stars 49 forks source link

when uniqid in vite project and typescript show error Uncaught Error: Module "os" has been externalized for browser compatibility. Cannot access "os.networkInterfaces" in client code. #45

Open gradyll opened 2 years ago

gradyll commented 2 years ago

when i import uniqid,it show this error:"Uncaught Error: Module "os" has been externalized for browser compatibility. Cannot access "os.networkInterfaces" in client code."

Why?

mryechkin commented 2 years ago

I just ran into this issue as well, and looks like that's because this package only exports CommonJS module format, and Vite doesn't polyfill those by default:

Screen Shot 2022-07-18 at 11 16 32 AM

I'm going to be looking for an ESM-compatible alternative personally.

Jonas096 commented 6 months ago

We are facing this issue as well