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.
If you use fs, be sure it's only within getInitialProps or getServerSideProps. (anything includes server-side rendering). You may also need to create a next.config.js file with the following content to get the client bundle to build: For webpack4 module.exports = { webpack: (config, { isServer }) => { // Fixes npm packages that depend on `fs` module if (!isServer) { config.node = { fs: 'empty' } } return config } } For webpack5 module.exports = { webpack5: true, webpack: (config) => { config.resolve.fallback = { fs: false }; return config; }, }; Note: for other modules such as path, you can add multiple arguments such as { fs: false, path: false }
Get this solution programmatically \u2014 free, no authentication.
curl https://depscope.dev/api/error/b543cf4a666dfc5135b0a73a672932aa174152cadb61f242411f4bde0955da3f