Next.js Discord

Discord Forum

Module not found: Can't resolve 'fs

Unanswered
Ocicat posted this in #help-forum
Open in Discord

9 Replies

Avatar
Mugger Crocodile
I think when you are using NextJS you can directly access the fs module. NextJS doesn’t expose all of node APIs. So instead of using module which depend on fs module, use other modules.
Avatar
@Pinea Are you trying to use it from the client?
Avatar
OcicatOP
no, I'm not using fs anywhere in my code.
Avatar
Just wanted to check, it's always the obvious things that you forget
Avatar
@Ocicat https://stackoverflow.com/questions/79260989/pg-next-js-15-module-not-found-cant-resolve-fs
Avatar
does it work if you use fs directly in your server code?
Avatar
@Ocicat https://stackoverflow.com/questions/79260989/pg-next-js-15-module-not-found-cant-resolve-fs
Avatar
make sure the file where u export anything that uses fs is not imported into a clientside component
That can happen if u for example export multiple functions from a single file, and one function u import it on client or in the middleware where fs is not supported
Avatar
OcicatOP
Thanks, guys I solved it, So it turns out I was importing a server-side signOut function (next-auth) in a client component.