Home > Software design >  SyntaxError: Unexpected token 'export' on NextJS auth integration
SyntaxError: Unexpected token 'export' on NextJS auth integration

Time:03-17

I've been working on a site with Next.js using next-auth and Prisma. Everything was working fine, however today the code doesn't work anymore. I just getting this error from any pages under [...nextauth].js

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/user/wwww/node_modules/ (next-auth/prisma-adapter/dist/index.js (1)
wrapSafe
internal/modules/cjs/loader.js (1001:16)
Module._compile
internal/modules/cjs/loader.js (1049:27)
Object.Module._extensions..js
internal/modules/cjs/loader.js (1114:10)
Module.load
internal/modules/cjs/loader.js (950:32)
Function.Module._load
internal/modules/cjs/loader.js (790:14)
Module.require
internal/modules/cjs/loader.js (974:19)
require
internal/modules/cjs/helpers.js (92:18)
Object.@next-auth/prisma-adapter
file:///Users/user/wwww/.next/server/pages/api/auth/[...nextauth].js (22:18)
__webpack_require__
file:///Users/user/wwww/.next/server/webpack-api-runtime.js (33:42)
eval
webpack-internal:///(api)/./src/pages/api/auth/[...nextauth].js (11:83)

Nothing was changed that would justify this (last changes were on html level) except for a small library update (prisma from 3.8.1 to 3.11.0 and next-auth from 4.2.1 to 4.3.0). I tried to revert to those versions but the error is still there.

CodePudding user response:

This issue is caused by a recent release of next-auth. The only option is to downgrade as of now as mentioned in this GitHub Issue.

This was caused by changing the outputs to ESM.

CodePudding user response:

I had the exact same problem! Also prisma installed and was coding out some HTML/JSX, maybe done a npm update but now it crashes. package.json is the same as before.

  • Related