Replies: 3 comments 4 replies
-
Any solution for this? I'm having the same problem and I can't find the solution.... 🤦🏻♂️ |
Beta Was this translation helpful? Give feedback.
-
I added ...
model User {
id String @id @default(auto()) @map("_id") @db.ObjectId
name String?
hashedPassword String?
email String? @unique
emailVerified DateTime?
image String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@map("user")
}
model Account {
id String @id @default(auto()) @map("_id") @db.ObjectId
type String
provider String
providerAccountId String
token_type String?
refresh_token String? @db.String
access_token String? @db.String
id_token String? @db.String
scope String?
session_state String?
expires_at Int?
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
userId String @db.ObjectId
@@unique([provider, providerAccountId])
@@map("account")
}
... |
Beta Was this translation helpful? Give feedback.
-
check this Docsyou need to make a model Account with the same fields name just copy it exactly this will fix your problem PS: I was writing refresh_token field like this -> refreshToken | this made my code return the same error you provided |
Beta Was this translation helpful? Give feedback.
-
Question 💬
I am having this error trying to implement next-auth in my next app:
Cannot read properties of undefined (reading 'findUnique') TypeError: Cannot read properties of undefined (reading 'findUnique') at getUserByAccount
Every time i try to sign up using google or github provider i end up having the same problem:
[next-auth][error][adapter_error_getUserByAccount]
https://next-auth.js.org/errors#adapter_error_getuserbyaccount Cannot read properties of undefined (reading 'findUnique') {
message: "Cannot read properties of undefined (reading 'findUnique')",
stack: "TypeError: Cannot read properties of undefined (reading 'findUnique')\n" +
' at getUserByAccount (webpack-internal:///(sc_server)/./node_modules/@auth/prisma-adapter/index.js:220:45)\n' +
' at _callee2$ (webpack-internal:///(sc_server)/./node_modules/next-auth/core/errors.js:301:43)\n' +
' at tryCatch (webpack-internal:///(sc_server)/./node_modules/@babel/runtime/helpers/regeneratorRuntime.js:36:25)\n' +
' at Generator.eval (webpack-internal:///(sc_server)/./node_modules/@babel/runtime/helpers/regeneratorRuntime.js:120:30)\n' +
' at Generator.eval [as next] (webpack-internal:///(sc_server)/./node_modules/@babel/runtime/helpers/regeneratorRuntime.js:64:29)\n' +
' at asyncGeneratorStep (webpack-internal:///(sc_server)/./node_modules/@babel/runtime/helpers/asyncToGenerator.js:4:28)\n' +
' at _next (webpack-internal:///(sc_server)/./node_modules/@babel/runtime/helpers/asyncToGenerator.js:22:17)\n' +
' at eval (webpack-internal:///(sc_server)/./node_modules/@babel/runtime/helpers/asyncToGenerator.js:27:13)\n' +
' at new Promise ()\n' +
' at eval (webpack-internal:///(sc_server)/./node_modules/@babel/runtime/helpers/asyncToGenerator.js:19:16)\n' +
' at Object.callback (webpack-internal:///(sc_server)/./node_modules/next-auth/core/routes/callback.js:42:49)\n' +
' at async AuthHandler (webpack-internal:///(sc_server)/./node_modules/next-auth/core/index.js:202:38)\n' +
' at async NextAuthRouteHandler (webpack-internal:///(sc_server)/./node_modules/next-auth/next/index.js:49:30)\n' +
' at async NextAuth._args$ (webpack-internal:///(sc_server)/./node_modules/next-auth/next/index.js:83:24)\n' +
' at async eval (webpack-internal:///(sc_server)/./node_modules/next/dist/server/future/route-modules/app-route/module.js:265:37)',
name: 'TypeError'
}
[next-auth][error][OAUTH_CALLBACK_HANDLER_ERROR]
https://next-auth.js.org/errors#oauth_callback_handler_error Cannot read properties of undefined (reading 'findUnique') TypeError: Cannot read properties of undefined (reading 'findUnique')
at getUserByAccount (webpack-internal:///(sc_server)/./node_modules/@auth/prisma-adapter/index.js:220:45)
at _callee2$ (webpack-internal:///(sc_server)/./node_modules/next-auth/core/errors.js:301:43)
at tryCatch (webpack-internal:///(sc_server)/./node_modules/@babel/runtime/helpers/regeneratorRuntime.js:36:25)
at Generator.eval (webpack-internal:///(sc_server)/./node_modules/@babel/runtime/helpers/regeneratorRuntime.js:120:30)
at Generator.eval [as next] (webpack-internal:///(sc_server)/./node_modules/@babel/runtime/helpers/regeneratorRuntime.js:64:29)
at asyncGeneratorStep (webpack-internal:///(sc_server)/./node_modules/@babel/runtime/helpers/asyncToGenerator.js:4:28)
at _next (webpack-internal:///(sc_server)/./node_modules/@babel/runtime/helpers/asyncToGenerator.js:22:17)
at eval (webpack-internal:///(sc_server)/./node_modules/@babel/runtime/helpers/asyncToGenerator.js:27:13)
at new Promise ()
at eval (webpack-internal:///(sc_server)/./node_modules/@babel/runtime/helpers/asyncToGenerator.js:19:16)
at Object.callback (webpack-internal:///(sc_server)/./node_modules/next-auth/core/routes/callback.js:42:49)
at async AuthHandler (webpack-internal:///(sc_server)/./node_modules/next-auth/core/index.js:202:38)
at async NextAuthRouteHandler (webpack-internal:///(sc_server)/./node_modules/next-auth/next/index.js:49:30)
at async NextAuth._args$ (webpack-internal:///(sc_server)/./node_modules/next-auth/next/index.js:83:24)
at async eval (webpack-internal:///(sc_server)/./node_modules/next/dist/server/future/route-modules/app-route/module.js:265:37) {
name: 'GetUserByAccountError',
code: undefined
}
THIS IS THE authOptions object:
https://github.com/Steravy/Airbnb-clone/blob/main/src/app/utils/authOptions.ts
THE PRISMA SCHEMA:
https://github.com/Steravy/Airbnb-clone/blob/main/prisma/schema.prisma
The CredentialsProvider is working just fine
How to reproduce ☕️
[next-auth][error][adapter_error_getUserByAccount]
https://next-auth.js.org/errors#adapter_error_getuserbyaccount Cannot read properties of undefined (reading 'findUnique') {
message: "Cannot read properties of undefined (reading 'findUnique')",
stack: "TypeError: Cannot read properties of undefined (reading 'findUnique')\n" +
' at getUserByAccount (webpack-internal:///(sc_server)/./node_modules/@auth/prisma-adapter/index.js:220:45)\n' +
' at _callee2$ (webpack-internal:///(sc_server)/./node_modules/next-auth/core/errors.js:301:43)\n' +
' at tryCatch (webpack-internal:///(sc_server)/./node_modules/@babel/runtime/helpers/regeneratorRuntime.js:36:25)\n' +
' at Generator.eval (webpack-internal:///(sc_server)/./node_modules/@babel/runtime/helpers/regeneratorRuntime.js:120:30)\n' +
' at Generator.eval [as next] (webpack-internal:///(sc_server)/./node_modules/@babel/runtime/helpers/regeneratorRuntime.js:64:29)\n' +
' at asyncGeneratorStep (webpack-internal:///(sc_server)/./node_modules/@babel/runtime/helpers/asyncToGenerator.js:4:28)\n' +
' at _next (webpack-internal:///(sc_server)/./node_modules/@babel/runtime/helpers/asyncToGenerator.js:22:17)\n' +
' at eval (webpack-internal:///(sc_server)/./node_modules/@babel/runtime/helpers/asyncToGenerator.js:27:13)\n' +
' at new Promise ()\n' +
' at eval (webpack-internal:///(sc_server)/./node_modules/@babel/runtime/helpers/asyncToGenerator.js:19:16)\n' +
' at Object.callback (webpack-internal:///(sc_server)/./node_modules/next-auth/core/routes/callback.js:42:49)\n' +
' at async AuthHandler (webpack-internal:///(sc_server)/./node_modules/next-auth/core/index.js:202:38)\n' +
' at async NextAuthRouteHandler (webpack-internal:///(sc_server)/./node_modules/next-auth/next/index.js:49:30)\n' +
' at async NextAuth._args$ (webpack-internal:///(sc_server)/./node_modules/next-auth/next/index.js:83:24)\n' +
' at async eval (webpack-internal:///(sc_server)/./node_modules/next/dist/server/future/route-modules/app-route/module.js:265:37)',
name: 'TypeError'
}
[next-auth][error][OAUTH_CALLBACK_HANDLER_ERROR]
https://next-auth.js.org/errors#oauth_callback_handler_error Cannot read properties of undefined (reading 'findUnique') TypeError: Cannot read properties of undefined (reading 'findUnique')
at getUserByAccount (webpack-internal:///(sc_server)/./node_modules/@auth/prisma-adapter/index.js:220:45)
at _callee2$ (webpack-internal:///(sc_server)/./node_modules/next-auth/core/errors.js:301:43)
at tryCatch (webpack-internal:///(sc_server)/./node_modules/@babel/runtime/helpers/regeneratorRuntime.js:36:25)
at Generator.eval (webpack-internal:///(sc_server)/./node_modules/@babel/runtime/helpers/regeneratorRuntime.js:120:30)
at Generator.eval [as next] (webpack-internal:///(sc_server)/./node_modules/@babel/runtime/helpers/regeneratorRuntime.js:64:29)
at asyncGeneratorStep (webpack-internal:///(sc_server)/./node_modules/@babel/runtime/helpers/asyncToGenerator.js:4:28)
at _next (webpack-internal:///(sc_server)/./node_modules/@babel/runtime/helpers/asyncToGenerator.js:22:17)
at eval (webpack-internal:///(sc_server)/./node_modules/@babel/runtime/helpers/asyncToGenerator.js:27:13)
at new Promise ()
at eval (webpack-internal:///(sc_server)/./node_modules/@babel/runtime/helpers/asyncToGenerator.js:19:16)
at Object.callback (webpack-internal:///(sc_server)/./node_modules/next-auth/core/routes/callback.js:42:49)
at async AuthHandler (webpack-internal:///(sc_server)/./node_modules/next-auth/core/index.js:202:38)
at async NextAuthRouteHandler (webpack-internal:///(sc_server)/./node_modules/next-auth/next/index.js:49:30)
at async NextAuth._args$ (webpack-internal:///(sc_server)/./node_modules/next-auth/next/index.js:83:24)
at async eval (webpack-internal:///(sc_server)/./node_modules/next/dist/server/future/route-modules/app-route/module.js:265:37) {
name: 'GetUserByAccountError',
code: undefined
}
Contributing 🙌🏽
Yes, I am willing to help answer this question in a PR
Beta Was this translation helpful? Give feedback.
All reactions