adrianhajdin / project_nextjs13_flexibble

https://jsmastery.pro
639 stars 133 forks source link

importing AdapterUser from next-auth/adapters showing module not found #28

Open meet2aman opened 11 months ago

meet2aman commented 11 months ago

while importing AdapterUser from next-auth/adapters showing module not found and its type declaration i tried almost all possible ways to resolve it.

import { getServerSession } from "next-auth/next"; import { NextAuthOptions, User } from "next-auth"; import { AdapterUser } from "next-auth/adapters"; import GoogleProvider from "next-auth/providers/google"; import jsonwebtoken from "jsonwebtoken"; import { JWT } from "next-auth/jwt"; import { SessionInterface } from "@/common.types";

export const authOptions: NextAuthOptions = { providers: [ GoogleProvider({ clientId: process.env.GOOGLE_CLIENT_ID!, clientSecret: process.env.GOOGLE_CLIENT_SECRET!, }), ], // jwt: { // encode: ({ secret, token }) => {}, // decode: async ({ secret, token }) => {}, // }, // theme: { // colorScheme: "light", // logo: "/logo.png", // }, callbacks: { async session({ session }) { return session; }, async signIn({ user }: { user: AdapterUser | User }) { try { // get the user if they exist /// if not create a new user ///return true if they exist or logged in return true; } catch (error: any) { console.log(error); return false; } }, }, };

DeoThemes commented 11 months ago

I got the same error. Here is the fix: edit your tsconfig.json and change moduleResolution to node

"moduleResolution": "node"