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.

Next.js: SyntaxError: Unexpected token 'export'

See original GitHub issue

Following the installation in readme with Next.js v9.3.6 (latest) has led to the following issue. SyntaxError: Unexpected token 'export' Looks like a cjs module not working in React. 🤔

ERROR (CLICK TO EXPAND!)

SyntaxError: Unexpected token ‘export’ (anonymous function) /Users/ahmadawais/…/node_modules/web-vitals/dist/web-vitals.min.js:1 Module._compile internal/modules/cjs/loader.js:892:18 Module._extensions…js internal/modules/cjs/loader.js:973:10 Module.load internal/modules/cjs/loader.js:812:32 Function.Module._load internal/modules/cjs/loader.js:724:14 Module.require internal/modules/cjs/loader.js:849:19 require internal/modules/cjs/helpers.js:74:18 web-vitals webpack:/external “web-vitals”:1

1 | module.exports = require(“web-vitals”); View compiled webpack_require ./webpack/bootstrap:21 18 | // Execute the module function 19 | var threw = true; 20 | try { 21 | modules[moduleId].call(module.exports, module, module.exports, webpack_require); | ^ 22 | threw = false; 23 | } finally { 24 | if(threw) delete installedModules[moduleId]; View compiled Module…/pages/index.js /_next/development/server/static/development/pages/index.js:4450:69 webpack_require ./webpack/bootstrap:21 18 | // Execute the module function 19 | var threw = true; 20 | try { 21 | modules[moduleId].call(module.exports, module, module.exports, webpack_require); | ^ 22 | threw = false; 23 | } finally { 24 | if(threw) delete installedModules[moduleId]; View compiled 3 /_next/development/server/static/development/pages/index.js:4996:18 webpack_require ./webpack/bootstrap:21 18 | // Execute the module function 19 | var threw = true; 20 | try { 21 | modules[moduleId].call(module.exports, module, module.exports, webpack_require); | ^ 22 | threw = false; 23 | } finally { 24 | if(threw) delete installedModules[moduleId]; View compiled ▶ 10 stack frames were collapsed. This screen is visible only in development. It will not appear if the app crashes in production. Open your browser’s developer console to further inspect this error.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
philipwaltoncommented, May 7, 2020

@ahmadawais I just released v0.2.1, which should fix this. Please give it a try and let me know if you’re still having issues.

1reaction
housseindjirdehcommented, May 12, 2020

@ahmadawais FYI web-vitals was included into Next.js core and merged upstream: https://github.com/zeit/next.js/pull/12650

With version 9.4, you’ll only need to create a reportWebVitals function in _app.js to track web vital metrics (among other custom performance marks and measures)

The Measuring Performance page in the docs explains this in detail 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Next.js SyntaxError "Unexpected token 'export'" - Stack Overflow
I was getting the same error: Unexpected token 'export' ; with a node_modules dependency made for the browser (client-side).
Read more >
SyntaxError: Unexpected token 'export' #31518 - vercel/next.js
Nextjs is failing on build of a third party package. The third party package is using ES6 syntax for exports. export { Root...
Read more >
Fixing "SyntaxError: Unexpected token 'export'" with NextJS
Fixing “SyntaxError: Unexpected token ”export”” with NextJS. I ran into an error when trying to use reactgrid with NextJS. The error was
Read more >
SyntaxError: Unexpected token 'export' in ScrollTrigger (Next.js)
Hello, I've used similar code in react before, but for some reason in Next.js, even simply importing ScrollTrigger causes this error.
Read more >
AmCharts in NextJS - SyntaxError: Unexpected token 'export'
Coding example for the question AmCharts in NextJS - SyntaxError: Unexpected token 'export'-Reactjs.
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