question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't resolve 'fs'

See original GitHub issue

Error compiling page in console:

[ ready ] compiled successfully ready at http://localhost:3000 [ event ] build page: / [ wait ] compiling ... [ error ] ./node_modules/destroy/index.js Module not found: Can't resolve 'fs' in ''C:\Users\admin\projects\gast\node_modules\destroy' Could not find files for /index in .next/build-manifest.json ModuleNotFoundError: Module not found: Error: Can't resolve 'fs' in 'C:\Users\admin\projects\gast\node_modules\destroy'

I have not used any new packages. It just came out of nowhere I tried to install all the packages again in a separate folder and transfer the necessary components there. Nothing has changed, the same error

https://github.com/treuh/solgastrobar

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

12reactions
jqhooglandcommented, Jul 17, 2021

For newer versions of next that use webpack5, use the following in your next.config.js instead (see for example):

 webpack: (config, { isServer }) => {
    // Fixes npm packages that depend on `fs` module
    if (!isServer) {
      config.resolve.fallback = {
        fs: false,
      };
    }

    return config;
  },
5reactions
timneutkenscommented, Dec 29, 2019

In general it means you’re importing a server-only dependency in code that will be shipped to client-side users.

@BjoernRave it’s not recommended to add that as server-only libs are generally massive and will bloat bundle size while working incompletely client-side.


Please follow the issue template.

https://github.com/zeit/next.js/issues/new/choose

https://github.com/zeit/next.js/issues/new?template=8.Question_about_next.md

# Question about Next.js

GitHub Issues are reserved for Bug reports and Feature requests. The best place to get your question answered is to post it on https://spectrum.chat/next-js.
Read more comments on GitHub >

github_iconTop Results From Across the Web

Module not found: Error: Can't resolve 'fs' in
I found a possible solution, that you have to put some configuration in one of the node_modules. But I think that is not...
Read more >
How To Solve Module Not Found Can't Resolve 'fs' in Next.js
The Module not found : Can't resolve 'fs' error and similar issues most likely occur when you try to import a module that...
Read more >
Can't resolve 'fs' error in Next.js and WebPack
The Module not found: Can't resolve 'fs' in Next.js error occurs when you import a Node.js module that is not available in the...
Read more >
Can't resolve 'fs' when bundle with webpack · Issue #447
I got this error when using the "fetch" library from npm. At first I got the same error but with other packages (...
Read more >
module not found error can't resolve 'fs' in react js
The "Module not found: Can't resolve 'fs'" error in React is caused by a missing or incorrect dependency. To solve this problem, you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found