NextAuth表达式不可调用错误

s6fujrry  于 2023-08-04  发布在  其他
关注(0)|答案(1)|浏览(112)

所以我在Next.js中使用next-auth学习身份验证。我遵循了文档,下面是我的app/api/auth/[...nextauth]/route.ts代码

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 };

字符串
我在这个文件中得到一个错误

This expression is not callable.
  Type 'typeof import("e:/Javascript/learnauth2/node_modules/next-auth/next")' has no call signatures.ts(2349)


我拥有的next-auth版本是4.22.2next版本是13.4.10
任何有关这方面的帮助是赞赏

p4rjhz4m

p4rjhz4m1#

我想我找到了解决这个问题的办法。我试了npm update和boom!没有错误。不知道主要问题是什么

相关问题