I can't import SessionProvider from Next-Auth. While importing it's showing this error.
"Module not found: Package path ./react is not exported from package E:\NextApp\portfolio_website-main\portfolio_website-main\node_modules\next-auth"
here is my code:(_app.js)
import { SessionProvider } from "next-auth/react"
export default function App({Component, pageProps: { session, ...pageProps }}) {
return (
<SessionProvider session={session}>
<Component {...pageProps}/>
</SessionProvider>
)
}
you might be on v3 where next-auth/client is still in use. Either import that or run npm i next-auth@beta to use v4
I had the same issue and manage to fix it. Basically, There is a bad version of Next Auth out there so to avoid it, remove the ^ symbol before the version number in your package.json file
You can see the warning in the documentation here.
So the next-auth line in your package.json should read like this:
{
...
"dependencies": {
...
"next-auth": "4.0.0-beta.4",
...
}
}
Instead of this:
{
...
"dependencies": {
...
"next-auth": "^4.0.0-beta.4",
...
}
}
After you have done that make sure to run npm i or yarn to ensure the packages are updated.
That should fix your issue although I am now getting a getSessionAndUser is not a function Type error 😱