Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

With next.js, why did I suddenly start seeing Module not found: Error: Can't resolve 'fs'?

I changed nothing, but am using "next": "9.4.4", and I see:

Module not found: Can't resolve 'fs' in 'web/node_modules/graceful-fs'
Could not find files for /app/d/[id] in .next/build-manifest.json
ModuleNotFoundError: Module not found: Error: Can't resolve 'fs' in 'web/node_modules/graceful-fs'

What could I be doing wrong?

like image 645
Shamoon Avatar asked Oct 16 '25 17:10

Shamoon


2 Answers

Looks like you're not in an /api directory. The client side code won't be able to import fs, only the API files will

like image 164
Fowad Avatar answered Oct 18 '25 06:10

Fowad


Your component might be rendering on the client-side. Check that places you assume are rendered on the server (getStaticProps/getServerSideProps) might be hydrating your component and trying to run code you think should run on the server actually on the client.

like image 29
funerr Avatar answered Oct 18 '25 08:10

funerr



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!