uuid: SyntaxError: Unexpected token 'export'

Describe the bug

It seems there is a problem with exporting different versions inside of uuid. My project is using uuidv4 which is using uuid.

To Reproduce

Steps to reproduce the behavior:

  1. Install ‘uuidv4’
  2. Run project (commonJs style)
  3. See error

Expected behavior

Expected to run without problem.

Runtime

  • OS: Win10
  • Runtime: Node.js
  • Runtime Version: 14.3.0

Additional context

You can see the error here:

...\node_modules\uuidv4\node_modules\uuid\dist\esm-browser\index.js:1
export { default as v1 } from './v1.js';
^^^^^^

SyntaxError: Unexpected token 'export'

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 20 (10 by maintainers)

Most upvoted comments

@riccardoNovaglia your node version has incomplete support for the package.exports feature. It’s also not actively supported by Node.js anymore, see https://nodejs.org/en/about/releases/

Please upgrade to Node.js v14 if you want to use ESM or downgrade to v12 if you want to use CommonJS.

@ctavan absolutely right. Can confirm it works with both v12 and v14. Thanks for the help!

Hey folks, I think this still might be an issue, getting exactly the same problem, importing uuid directly.

Made a repo here to show the problem.

Versions:

➜  tmp git:(master) node --version
v13.2.0
➜  tmp git:(master) npm --version
6.14.7

Hope it helps