uuidjs/uuid

'exports is not defined' typescirpt when importing uuid

frostzt opened this issue · 2 comments

Describe the bug

require is not defined and exports is not defined in console if used for node or es6 syntax both. I am using typescript 4.2 but the problem pops up as I import uuid and goes away if removed!

How to reproduce

Can be reproduced for both require is not defined and exports is not defined.
To reproduce simply import using es6 syntax: import { v4 } from 'uuid';

Expected behavior

Expected v4() to generate a uuid but instead it crashed the entire application!

Runtime

  • OS: [e.g. macOS, Linux]
  • Runtime: Node.js
  • Runtime Version: 14.16.1

Additional information

[Any other information or comments that you think will help]

Hi, could you please create a repository with reproduction? It's not clear from description where the issue comes from.

Works for me.

$ cat package.json
{
  "name": "uuid_es6",
  "version": "1.0.0",
  "type": "module",
  "main": "index.js",
  "dependencies": {
    "uuid": "8.3.2"
  }
}

$ cat index.js
import {v4} from 'uuid';

console.log(v4());

$ node --version
v14.16.1

$ node index.js
77499efc-e6da-4ff3-9495-b210664c308a

Closing per our stated policy. 'Will reopen if/when OP provides a Minimal, Complete, and Verifiable example.