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

Adapter type

@next-auth/prisma-adapter

Environment

  System:
    OS: macOS 12.2.1
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 91.80 MB / 16.00 GB
    Shell: 3.3.1 - /usr/local/bin/fish
  Binaries:
    Node: 16.13.2 - /usr/local/bin/node
    Yarn: 1.22.17 - ~/.yarn/bin/yarn
    npm: 8.1.2 - /usr/local/bin/npm
  Browsers:
    Brave Browser: 90.1.23.73
    Chrome: 99.0.4844.74
    Firefox: 98.0
    Safari: 15.3
  npmPackages:
    next: 12.1.0 => 12.1.0 
    next-auth: ^4.3.0 => 4.3.0 
    react: 17.0.2 => 17.0.2 


  npmPackages:
    @next-auth/prisma-adapter: ^1.0.2 => 1.0.2 

Reproduction URL

https://github.com/bmichotte/prisma-adapter

Describe the issue

When using @next-auth/prisma-adapter version 1.0.2, the following issue appears

image

(copy-paste here, sorry for the identation)

Server Error

SyntaxError: Unexpected token 'export'
This error happened while generating the page. Any console logs will be displayed in the terminal window.
Call Stack
<unknown>
/Users/benjamin/Developer/tests/prisma-adapter/node_modules/ (next-auth/prisma-adapter/dist/index.js (1)
Object.compileFunction
node:vm (352:18)
wrapSafe
node:internal/modules/cjs/loader (1031:15)
Module._compile
node:internal/modules/cjs/loader (1065:27)
Object.Module._extensions..js
node:internal/modules/cjs/loader (1153:10)
Module.load
node:internal/modules/cjs/loader (981:32)
Function.Module._load
node:internal/modules/cjs/loader (822:12)
Module.require
node:internal/modules/cjs/loader (1005:19)
require
node:internal/modules/cjs/helpers (102:18)
Object.@next-auth/prisma-adapter
file:/Users/benjamin/Developer/tests/prisma-adapter/.next/server/pages/api/auth/[...nextauth].js (22:18)
__webpack_require__
file:/Users/benjamin/Developer/tests/prisma-adapter/.next/server/webpack-api-runtime.js (33:42)

How to reproduce

git clone https://github.com/bmichotte/prisma-adapter
yarn install
yarn dev

then open http://localhost:3000

You should be redirected to http://localhost:3000/api/auth/error?error=Configuration because Prisma is not configured, but even with a configuration, you have the same error

Expected behavior

Using version 1.0.1, you have the correct error

image

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:9
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
balazsorban44commented, Mar 16, 2022

This seems to have been caused by our recent monorepo change. It looks like we accidentally changed the outputs to ESM. Downgrading to 1.0.1 would be the workaround for now. @ThangHuuVu or I will be able to look at this soon, thanks for reporting! I assume our tsconfig needs some tweaking.

Other adapters might be affected as well, see https://github.com/nextauthjs/next-auth/releases

2reactions
goforbgcommented, Mar 17, 2022

@balazsorban44 @JoaoFOliveira Had the same issue with Mongo db adapter, Here’s my new package.json that worked for me, downgrading next to 12.0.1 made no change, but downgrading to 1.0.1 fixed it.

“dependencies”: { “@crewcharge/core”: “^1.0.5”, @next-auth/mongodb-adapter”: “1.0.1”, “mongodb”: “^4.4.0”, “next”: “^12.1.0”, “next-auth”: “4.2.1”, },

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting Unexpected Token Export - javascript - Stack Overflow
The problem was that I was changing my code from non-modules to modules and I forgot to delete the imported script file. My...
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