“下一个认证/反应"在 next-auth 中制作自定义电子邮件登录页面时找不到模块 [英] "next-auth/react" module not found when making custom email sign in page in next-auth
问题描述
我正在为身份验证部分制作一个带有 next-auth 的 NextJs 应用程序.使用 next-auth 自己的默认页面成功实现了电子邮件登录.
I'm making a NextJs application with next-auth for the authentication part. Email Sign In is successfully implemented using next-auth's own default pages.
但现在我想要一个自定义登录页面.我为此遵循了 文档,并添加了pages: { signIn: '/auth/signin' }
在我的 [...nextauth].js 文件中.然后,我在 pages/auth/signin.js.但是在运行 yarn dev
时,我得到了 this module not found 错误:
But now I would like to have a custom sign in page. I followed the documentation for this, and added
pages: { signIn: '/auth/signin' }
in my [...nextauth].js file. Then, I added the given Email Sign In code in pages/auth/signin.js.
But upon running yarn dev
, I get this module not found error:
error - ./pages/api/auth/signin.js:1:0
Module not found: Package path ./react is not exported from package C:...
ode_modules
ext-auth (see exports field in C:...
ode_modules
ext-authpackage.json)
> 1 | import { getCsrfToken } from "next-auth/react"
2 |
3 | export default function SignIn({ csrfToken }) {
4 | return (
Import trace for requested module:
https://nextjs.org/docs/messages/module-not-found
我在 npm 或 yarn 网站中找不到任何名为next-auth/react"的模块.即使在 node_modules 的 next-auth 文件夹中,也没有 'react' 命名文件...
And I couldn't find any module named 'next-auth/react' in npm or yarn websites. Even in next-auth folder in node_modules, there is no 'react' named file...
我该如何解决这个问题?我在这里做错了吗?
How can I solve this? And am I doing anything wrong here?
推荐答案
我遇到了同样的问题 &当使用 next-auth/react
时,我意识到文档适用于 v4 &使用 next-auth/client
时,您可能正在使用 v3.
I faced the same issue & I realised the docs are for v4 when next-auth/react
is used & you are probably on v3 when next-auth/client
was used.
要使用测试版,请执行以下操作:
To use the beta version, do:
➜ npm i next-auth@beta
这应该可以解决!
这篇关于“下一个认证/反应"在 next-auth 中制作自定义电子邮件登录页面时找不到模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!