Categories
JavaScript Answers

How to fix Module not found: Can’t resolve ‘fs’ in Next.js application with JavaScript?

Spread the love

To fix Module not found: Can’t resolve ‘fs’ in Next.js application with JavaScript, we set the fs option to false.

For instance, we write

module.exports = {
  webpack5: true,
  webpack: (config) => {
    config.resolve.fallback = { fs: false };

    return config;
  },
};

in webpack.config.js to set fs to false to disable the use of the fs module in the browser environment.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published.