SyntaxError: Unexpected token 'export'
See original GitHub issueDescribe 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:
- Install ‘uuidv4’
- Run project (commonJs style)
- 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:
- Created 3 years ago
- Comments:20 (10 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub 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 tov12
if you want to use CommonJS.@ctavan absolutely right. Can confirm it works with both v12 and v14. Thanks for the help!