我正在React/Next.js中创建我的第一个项目,使用NextAuth.js进行8月-N。我正在松散地跟踪NextAuth网站上的入门指南,并创建了一个包含以下代码的...nextauth.js页面:
import NextAuth from 'next-auth';
import GoogleProvider from 'next-auth/providers/google';
export default NextAuth({
providers: [
GoogleProvider({
clientId: process.env.GOOGLE_CLIENT_ID,
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
})
]
})我在包含以下代码的Header.js页面中使用提供程序:
...
import {useSession, signIn, signOut} from 'next-auth/react';
const Header = () => {
const { data: session } = useSession()
...
return (
<header className="border-b border-gray-100 dark:border-gray-700">
<div className="container mx-auto px-4 sm:px-6 py-4 flex justify-between items-center">
<Logo />
<div className={"flex items-center space-x-1 sm:space-x-2"}>
{!session ? (
<button type="button" onClick={() => signIn()} className="bg-blue-700 text-white px-4 py-2 rounded-md focus:outline-none focus:ring-4 focus:ring-blue-600 focus:ring-opacity-50 whitespace-nowrap">Sign in</button>
) : (
<button type="button" onClick={() => signOut()} className="bg-blue-700 text-white px-4 py-2 rounded-md focus:outline-none focus:ring-4 focus:ring-blue-600 focus:ring-opacity-50 whitespace-nowrap">Sign out</button>
)}
</div>
</div>
</header>
)
};
export default Header;但是,当我使用'npm‘旋转我的站点并尝试登录时,我会得到以下错误:
Server Error
Error: Package subpath './providers/google' is not defined by "exports" in /Users/tysont/Workspace/brightnote/node_modules/next-auth/package.json我使用的是NextAuth 4.0.6,在本地或GitHub中,没有看到在NextAuth package.json中任何地方都提到了特定于/google的导出。应该有吗?我遗漏了什么?
发布于 2021-12-31 02:05:46
https://stackoverflow.com/questions/70523435
复制相似问题