question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SyntaxError: Unexpected token 'export'

See original GitHub issue

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'

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:20 (10 by maintainers)

github_iconTop GitHub Comments

3reactions
ctavancommented, Aug 5, 2020

@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.

2reactions
riccardoNovagliacommented, Aug 5, 2020

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting Unexpected Token Export - javascript - Stack Overflow
I solved it by declaring a type as a module when adding a script tag in my index. html file.
Read more >
SyntaxError: Unexpected token 'export' in JavaScript
To solve the "Uncaught SyntaxError Unexpected token 'export'" error, set the type property to module in your package.json file.
Read more >
How to fix SyntaxError: Unexpected token 'export' in JavaScript?
In this article, we are going to see How to fix SyntaxError: Unexpected token 'export' in JavaScript? and what are Es6 modules.
Read more >
SyntaxError: Unexpected token 'export' - Abhishek Kumar
In case you are getting error like 'Unexpected token export' while starting the server, then export like below in schema.js
Read more >
How to Solve Unexpected Token 'export' Error in JavaScript
To solve the "Uncaught SyntaxError Unexpected token 'export'" error, set the type property to module in your package.json file.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found