Getting this error after added next-auth module to my nextjs app i tried setting node fs to empty. But it lead to other issues and the app completely stops working.
Enclosed the log below for your reference.
`D:\Code\link-api>npm run build
[email protected] build D:\Code\link-api
next build
Failed to build
{ Error: (client) ./node_modules/next-auth/node_modules/destroy/index.js
Module not found: Error: Can't resolve 'fs' in 'D:\Code\link-api\node_modules\next-auth\node_modules\destroy'
@ ./node_modules/next-auth/node_modules/destroy/index.js 14:17-30
@ ./node_modules/next-auth/node_modules/send/index.js
@ ./node_modules/next-auth/node_modules/express/lib/response.js
@ ./node_modules/next-auth/node_modules/express/lib/express.js
@ ./node_modules/next-auth/node_modules/express/index.js`
Thanks!
Thanks for raising the issue.
It looks like it's maybe it's specific to Windows, I'll take a look.
@utpal7ch , I too got this issue yesterday and after an hour of frustrating google search, i had a duh moment, and the mistake was i used the wrong import statement.
DON'T DO the below import in client pages;
import NextAuth from "next-auth";
DO this instead.
import NextAuth from "next-auth/client";
Most helpful comment
@utpal7ch , I too got this issue yesterday and after an hour of frustrating google search, i had a duh moment, and the mistake was i used the wrong import statement.
DON'T DO the below import in client pages;
import NextAuth from "next-auth";DO this instead.
import NextAuth from "next-auth/client";