{"id":404,"hash":"b543cf4a666dfc5135b0a73a672932aa174152cadb61f242411f4bde0955da3f","pattern":"Module not found: Can&#39;t resolve &#39;fs&#39; in Next.js application","full_message":"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.","ecosystem":"npm","package_name":"node.js","package_version":null,"solution":"If you use fs, be sure it's only within getInitialProps or getServerSideProps. (anything includes server-side rendering).\n\nYou may also need to create a next.config.js file with the following content to get the client bundle to build:\n\nFor webpack4\n\nmodule.exports = {\n  webpack: (config, { isServer }) => {\n    // Fixes npm packages that depend on `fs` module\n    if (!isServer) {\n      config.node = {\n        fs: 'empty'\n      }\n    }\n\n    return config\n  }\n}\n\nFor webpack5\n\nmodule.exports = {\n  webpack5: true,\n  webpack: (config) => {\n    config.resolve.fallback = { fs: false };\n\n    return config;\n  },\n};\n\nNote: for other modules such as path, you can add multiple arguments such as\n\n{\n  fs: false,\n  path: false\n}","confidence":0.95,"source":"stackoverflow","source_url":"https://stackoverflow.com/questions/64926174/module-not-found-cant-resolve-fs-in-next-js-application","votes":167,"created_at":"2026-04-19T04:51:06.837676+00:00","updated_at":"2026-04-19T04:51:06.837676+00:00"}