NodeJS Next-auth使用oauth登录时无效的`p.account.findUnique()` invocation”

lvjbypge  于 2023-06-29  发布在  Node.js
关注(0)|答案(1)|浏览(125)

在我的Next.js应用程序中,我使用next-auth进行身份验证,使用@next-auth/prisma-adapter和MySQL作为数据库提供程序。当我尝试使用OAuth登录时,我得到以下错误:

https://next-auth.js.org/errors#adapter_error_getuserbyaccount 
Invalid `p.account.findUnique()` invocation in
/Users/vignesh/projects/bmi-api/node_modules/@next-auth/prisma-adapter/dist/index.js:211:45

  208 getUserByEmail: (email) => p.user.findUnique({ where: { email } }),
  209 async getUserByAccount(provider_providerAccountId) {
  210     var _a;
→ 211     const account = await p.account.findUnique(
The column `(not available)` does not exist in the current database. {
  message: '\n' +
    'Invalid `p.account.findUnique()` invocation in\n' +
    '/Users/vignesh/projects/bmi-api/node_modules/@next-auth/prisma-adapter/dist/index.js:211:45\n' +
    '\n' +
    '  208 getUserByEmail: (email) => p.user.findUnique({ where: { email } }),\n' +
    '  209 async getUserByAccount(provider_providerAccountId) {\n' +
    '  210     var _a;\n' +
    '→ 211     const account = await p.account.findUnique(\n' +
    'The column `(not available)` does not exist in the current database.',
  stack: 'Error: \n' +
    'Invalid `p.account.findUnique()` invocation in\n' +
    '/Users/vignesh/projects/bmi-api/node_modules/@next-auth/prisma-adapter/dist/index.js:211:45\n' +
    '\n' +
    '  208 getUserByEmail: (email) => p.user.findUnique({ where: { email } }),\n' +
    '  209 async getUserByAccount(provider_providerAccountId) {\n' +
    '  210     var _a;\n' +
    '→ 211     const account = await p.account.findUnique(\n' +
    'The column `(not available)` does not exist in the current database.\n' +
    '    at Zr.handleRequestError (/Users/vignesh/projects/bmi-api/node_modules/@prisma/client/runtime/library.js:171:6414)\n' +
    '    at Zr.handleAndLogRequestError (/Users/vignesh/projects/bmi-api/node_modules/@prisma/client/runtime/library.js:171:5948)\n' +
    '    at Zr.request (/Users/vignesh/projects/bmi-api/node_modules/@prisma/client/runtime/library.js:171:5786)\n' +
    '    at async t._request (/Users/vignesh/projects/bmi-api/node_modules/@prisma/client/runtime/library.js:174:10455)\n' +
    '    at async getUserByAccount (/Users/vignesh/projects/bmi-api/node_modules/@next-auth/prisma-adapter/dist/index.js:211:29)',
  name: 'Error'
}
[next-auth][error][OAUTH_CALLBACK_HANDLER_ERROR] 
https://next-auth.js.org/errors#oauth_callback_handler_error 
Invalid `p.account.findUnique()` invocation in
/Users/vignesh/projects/bmi-api/node_modules/@next-auth/prisma-adapter/dist/index.js:211:45

  208 getUserByEmail: (email) => p.user.findUnique({ where: { email } }),
  209 async getUserByAccount(provider_providerAccountId) {
  210     var _a;
→ 211     const account = await p.account.findUnique(
The column `(not available)` does not exist in the current database. Error: 
Invalid `p.account.findUnique()` invocation in
/Users/vignesh/projects/bmi-api/node_modules/@next-auth/prisma-adapter/dist/index.js:211:45

  208 getUserByEmail: (email) => p.user.findUnique({ where: { email } }),
  209 async getUserByAccount(provider_providerAccountId) {
  210     var _a;
→ 211     const account = await p.account.findUnique(
The column `(not available)` does not exist in the current database.
    at Zr.handleRequestError (/Users/vignesh/projects/bmi-api/node_modules/@prisma/client/runtime/library.js:171:6414)
    at Zr.handleAndLogRequestError (/Users/vignesh/projects/bmi-api/node_modules/@prisma/client/runtime/library.js:171:5948)
    at Zr.request (/Users/vignesh/projects/bmi-api/node_modules/@prisma/client/runtime/library.js:171:5786)
    at async t._request (/Users/vignesh/projects/bmi-api/node_modules/@prisma/client/runtime/library.js:174:10455)
    at async getUserByAccount (/Users/vignesh/projects/bmi-api/node_modules/@next-auth/prisma-adapter/dist/index.js:211:29) {
  name: 'GetUserByAccountError',
  code: 'P2022'
}

依赖关系

{
"dependencies":{
    "next": "13.4.4",
    "next-auth": "^4.22.1",
    "prisma": "4.11.0",
    "@next-auth/prisma-adapter": "^1.0.7",

}

项目仓库https://github.com/alphawhiskey03/bmi-api

ymdaylpp

ymdaylpp1#

我已经安装了我下面提到的软件包的旧版本。
1.我更新了next-authprisma@prisma/client到它们的最新版本。
1.已确保prisma@prisma/client的版本相同。
1.做了yarn prisma db pushyarn prisma generate
一切都在这之后开始顺利进行。

相关问题