SyntaxError: Unexpected token 'export' on NextJS auth integration

SyntaxError: Unexpected token 'export' on NextJS auth integration

我一直在 Next.js 使用 next-auth 和 Prisma 开发一个网站。 一切正常,但是今天代码不再工作了。我刚从 [...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)

除了一个小的库更新(prisma 从 3.8.13.11.0 和 next-auth 从 4.2.14.3.0)。我试图恢复到那些版本,但错误仍然存​​在。

此问题是由 next-auth 的最新版本引起的。唯一的选择是按照 GitHub Issue.

中所述,从现在开始降级

这是由于将输出更改为 ESM 造成的。