将 Prisma Adapter 与 Next Auth 集成 - 意外的令牌“导出”
我正在尝试使用 vercel 指南进行编码: https://vercel.com/guides/ nextjs-prisma-postgres。尝试将 adapter: PrismaAdapter(prisma)
添加到 [...nextauth].ts
时,我收到错误 Unexpected token 'export'。根据所附图像 - 它似乎源自 prisma_adapter 内的 node_modules 文件夹。
[...nextauth].ts:
import NextAuth from "next-auth";
import GithubProvider from "next-auth/providers/github";
import { PrismaAdapter } from "@next-auth/prisma-adapter";
import prisma from "../../../lib/prisma";
export default NextAuth({
providers: [
GithubProvider({
clientId: process.env.GITHUB_ID,
clientSecret: process.env.GITHUB_SECRET,
}),
],
adapter: PrismaAdapter(prisma),
secret: process.env.SECRET,
});
package.json:
{
"name": "hello-next",
"version": "1.0.0",
"description": "",
"scripts": {
"dev": "next",
"build": "next build",
"start": "next start"
},
"keywords": [],
"author": "",
"license": "MIT",
"dependencies": {
"@next-auth/prisma-adapter": "^1.0.2",
"@prisma/client": "^3.11.0",
"next": "12.0.10",
"next-auth": "^4.3.0",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-markdown": "8.0.0"
},
"devDependencies": {
"@types/node": "^17.0.14",
"@types/react": "17.0.38",
"prisma": "^3.11.0",
"ts-node": "^10.7.0",
"typescript": "^4.5.5"
}
}
tsconfig.json:
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": false,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true
},
"exclude": ["node_modules"],
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "lib/prisma.tsx"]
}
I am trying to code-along with a vercel guide: https://vercel.com/guides/nextjs-prisma-postgres. I am getting an error Unexpected token 'export' when trying to add adapter: PrismaAdapter(prisma)
to [...nextauth].ts
. Per the attached image - it seems to originate in the node_modules folder inside prisma_adapter.
[...nextauth].ts:
import NextAuth from "next-auth";
import GithubProvider from "next-auth/providers/github";
import { PrismaAdapter } from "@next-auth/prisma-adapter";
import prisma from "../../../lib/prisma";
export default NextAuth({
providers: [
GithubProvider({
clientId: process.env.GITHUB_ID,
clientSecret: process.env.GITHUB_SECRET,
}),
],
adapter: PrismaAdapter(prisma),
secret: process.env.SECRET,
});
package.json:
{
"name": "hello-next",
"version": "1.0.0",
"description": "",
"scripts": {
"dev": "next",
"build": "next build",
"start": "next start"
},
"keywords": [],
"author": "",
"license": "MIT",
"dependencies": {
"@next-auth/prisma-adapter": "^1.0.2",
"@prisma/client": "^3.11.0",
"next": "12.0.10",
"next-auth": "^4.3.0",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-markdown": "8.0.0"
},
"devDependencies": {
"@types/node": "^17.0.14",
"@types/react": "17.0.38",
"prisma": "^3.11.0",
"ts-node": "^10.7.0",
"typescript": "^4.5.5"
}
}
tsconfig.json:
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": false,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true
},
"exclude": ["node_modules"],
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "lib/prisma.tsx"]
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是最新
@next-auth/prisma 中的一个错误 -adapter
版本,降级到1.0.1
是目前唯一的解决方法。this is a bug in the latest
@next-auth/prisma-adapter
version, downgrading to1.0.1
is the only workaround for the moment.此问题是由最近版本引起的下一个授权的。唯一的选择是按照 GitHub Issue< 中所述降级/a>.
其根本原因是由于将输出更改为 ESM 造成的。
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.
Root cause of this was caused by changing the outputs to ESM.