Skip to content

Nextjs 14.1 Build Errors Module not found : "fs" (not noticed in 14.0.3) #61153

Answered by prasad-pul
prasad-pul asked this question in Help
Discussion options

You must be logged in to vote

For anyone curious, I was able to fix this issue with this hack from earlier post:

The key thing to note here is using typeof nextRuntime === "undefined" and NOT isServer option ( I tried this and it doesn't help!)

It's interesting that I didn't have to do this (modify webpack config) in 14.0.3 but I have to do it for 14.1.0 🤔

/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: true,
  webpack: (config, { nextRuntime }) => {
    if (typeof nextRuntime === "undefined") {
      config.resolve.fallback = {
        ...config.resolve.fallback,
        fs: false,
        net: false,
        tls: false,
      };
    }
    config.externals.push("pino-pretty", "lokijs"…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by prasad-pul
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
1 participant