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.

Unexpected token export

See original GitHub issue

I’m using the material ui pickers in a server-rendered NextJs application. The date time picker works fine on the first load, but when I refresh the page it gives me the following error.

Unexpected token export
/path/to/my/project/node_modules/material-ui-pickers/index.js:1
(function (exports, require, module, __filename, __dirname) { export { default as DatePicker } from './DatePicker/DatePickerWrapper';
                                                              ^^^^^^

SyntaxError: Unexpected token export
    at createScript (vm.js:74:10)
    at Object.runInThisContext (vm.js:116:10)
    at Module._compile (module.js:537:28)
    at Module._compile (/path/to/my/project/node_modules/source-map-support/source-map-support.js:492:25)
    at Object.Module._extensions..js (module.js:584:10)
    at Module.load (module.js:507:32)
    at tryModuleLoad (module.js:470:12)
    at Function.Module._load (module.js:462:3)
    at Module.require (module.js:517:17)
    at require (internal/module.js:11:18)

What could be cause for this error?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
dmtrKovalenkocommented, Dec 2, 2017

@tharakabimal @alitaheri I think we will just add the cjs build reference to “main” and it would works, because I think we should support mostly es modules. I will publish an extra release today, will fix that too

1reaction
dmtrKovalenkocommented, Dec 2, 2017

Was fixed in 1.0.0-beta.7

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting Unexpected Token Export - javascript - Stack Overflow
You are using EcmaScript Module (ESM or 'ES6 Modules') syntax but your environment does not support it. NodeJS versions prior to v14.13.0 do...
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 >
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 >
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 >

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