Nextjs 14.1 Build Errors Module not found : "fs"

135 views Asked by At

My (Nextjs) project has a dependency on a external package which exports mostly browser compatible code but also exports some utility function that depend on some nodejs specific modules (for e.g. "fs").

This external package is being imported into both client & server components.

I am currently using Nextjs version 14.0.3 and the production build (next build) runs fine without any errors. Webpack tree-shakes only the requested modules in the client bundle

But if I upgrade to Nextjs version 14.1.0 I started seeing build errors : Module not found: "fs".

I tried different options:

  • Making the client component that imports this external package dynamic with ssr: false
  • changing the webpack in next.config : setting config.resolve.fallback: {fs: false}

But none of these changes seem to help.

Anything changed with the Webpack resolution in Nextjs 14.1 ??

I tried different options:

  • Making the client component that imports this external package dynamic with ssr: false
  • changing the webpack in next.config : setting config.resolve.fallback: {fs: false}
0

There are 0 answers