So I was learning authentication in Next.js using next-auth. I followed the documentation and here is my app/api/auth/[...nextauth]/route.ts
code
import NextAuth, { type NextAuthOptions } from "next-auth";
import GithubProvider from "next-auth/providers/github";
import CredentialsProvider from "next-auth/providers/credentials";
export const authOptions: NextAuthOptions = {
providers: [
GithubProvider({
clientId: process.env.GITHUB_ID as string,
clientSecret: process.env.GITHUB_SECRET as string,
}),
CredentialsProvider({
name: "Credentials",
credentials: {
username: {
label: "Username",
type: "text",
placeholder: "John Smith",
},
password: {
label: "Password",
type: "password",
placeholder: "*******",
},
},
async authorize(credentials) {
// here data should come from the database
const user = { id: "1", name: "John", password: "pass" };
if (
credentials?.username === user.name &&
credentials.password === user.password
) {
return user;
} else {
return null;
}
},
}),
],
};
const handler = NextAuth(authOptions);
export { handler as GET, handler as POST };
I am getting an error in this file that says
This expression is not callable.
Type 'typeof import("e:/Javascript/learnauth2/node_modules/next-auth/next")' has no call signatures.ts(2349)
The version of next-auth
I have is 4.22.2
and that of next
is 13.4.10
Any help regarding this is appreciated
2
Answers
So I guess I found a solution to this issue. I tried
npm update
and boom! There were no errors. No idea what the main issue wasi have the same error and when i make npm update anything append. Can have i help please?