Can't resolve 'fs' but in an API route???
Any idea why this error is occuring? I thought all api routes are node compatible...
Thanks a lot
7 Replies
Hey Philip, does this SO post help? https://stackoverflow.com/questions/64926174/module-not-found-cant-resolve-fs-in-next-js-application
Stack Overflow
Module not found: Can't resolve 'fs' in Next.js application
Unable to identify what's happening in my next.js app. As fs is a default file system module of nodejs. It is giving the error of module not found.
I mean, I only use fs in the API route. Do I really need to change the next config? Feels a bit weird since app router is pretty server-first, isn't it?
I think I found the problem
Ahh nice what is it?
Seems like the nextRuntime cannot be edge but has to be nodejs.
oic, good find!
Thanks for the help
yw! glad you found an answer 🙂