Next-auth: Module not found: Error: Can't resolve fs after adding next-auth

Created on 6 Jul 2018  路  2Comments  路  Source: nextauthjs/next-auth

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!

bug

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";

All 2 comments

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";

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghoshnirmalya picture ghoshnirmalya  路  3Comments

ryanditjia picture ryanditjia  路  3Comments

iaincollins picture iaincollins  路  3Comments

SharadKumar picture SharadKumar  路  3Comments

bscaspar picture bscaspar  路  3Comments