SyntaxError: Unexpected token 'export'
See original GitHub issueAdapter type
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
(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
Issue Analytics
- State:
- Created 2 years ago
- Reactions:9
- Comments:11 (1 by maintainers)
Top 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 >
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 Free
Top 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
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 ourtsconfig
needs some tweaking.Other adapters might be affected as well, see https://github.com/nextauthjs/next-auth/releases
@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”, },