Module not found: Can't resolve 'fs
Unanswered
Ocicat posted this in #help-forum
9 Replies
@Ocicat https://stackoverflow.com/questions/79260989/pg-next-js-15-module-not-found-cant-resolve-fs
Are you trying to use it from the client?
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.
@Pinea Are you trying to use it from the client?
OcicatOP
no, I'm not using fs anywhere in my code.
Just wanted to check, it's always the obvious things that you forget
@Ocicat https://stackoverflow.com/questions/79260989/pg-next-js-15-module-not-found-cant-resolve-fs
does it work if you use fs directly in your server code?
@Ocicat https://stackoverflow.com/questions/79260989/pg-next-js-15-module-not-found-cant-resolve-fs
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
OcicatOP
Thanks, guys I solved it, So it turns out I was importing a server-side
signOut
function (next-auth) in a client component.