我正在将我的项目迁移到nextjs 13.4中的app/目录,当我尝试在服务器组件中使用getServerSession()
访问会话时:
import { authOptions } from "@/pages/api/auth/[...nextauth]";
import { getServerSession } from "next-auth";
import Link from "next/link";
export default async function Navbar() {
const session = await getServerSession(authOptions);
return (
<div className="navbar top-0">
<div className="navbar-start">LOGO</div>
<div className="navbar-center"></div>
<div className="navbar-end">
<ul className="menu menu-horizontal px-1">
<li>
<Link href={"/example"}>Avatar Studio</Link>
</li>
<li>
<Link href={"/example"}>Calendar</Link>
</li>
<li>
<Link href={"/example"}>Newsfeed</Link>
</li>
<li>
<Link href={"/example"}>Profile</Link>
</li>
</ul>
</div>
</div>
);
}
它抛出:
./node_modules/next-auth/core/pages/index.js:10:51
Module not found: Can't resolve 'preact-render-to-string'
1条答案
按热度按时间slsn1g291#
我通过将导入从
next-auth
更改为next-auth/next
来解决它,直到我删除node_modules并重新安装,它仍然显示错误