1

I have been working with webpack today, and all of a sudden it starts throwing me errors that it can't resolve common node modules like fs and inspect. I found this github issue that gives a workaround by setting the modules to none through webpack's config. After doing that, I got this error in my browser: Browser Error

I believe that this pertains to the fact that in the workaround the modules were replaced by empty placeholders. I have already tried re-installing all of the modules. Hopefully somebody can help with this!

Artem Fedotov
  • 432
  • 1
  • 6
  • 21
  • Where are you trying to run this webpack code? In nodejs or in the browser? You cannot use the `fs` module in Javascript code that runs in the browser. The `fs` module only runs within nodejs. The same is true for the `net` module, the `http` module and others. – jfriend00 Oct 31 '20 at 03:20
  • I am not using the `fs` module in any of my client-side code. Webpack was working fine before and then all of a sudden in a production build it did this. This is not a problem with my code, and is probably a problem with probably either npm or webpack. – Impossible Reality Oct 31 '20 at 20:38
  • Are you 200% sure that you're not using some module that itself uses the `fs` module? Something is apparently attempting to load the `fs` module. – jfriend00 Oct 31 '20 at 20:40
  • Yes I am 200% sure that I am not using any node modules that should do that, and that I am not using the module itself. Again, It worked before for development builds but stopped working after trying to do a production build, with nothing changed in the code. – Impossible Reality Oct 31 '20 at 21:00

1 Answers1

0

try this:

fix the problem by changing webpack.config.js:

var config = Encore.getWebpackConfig();
config.node = { fs: 'empty' };
module.exports = config;
Dharman
  • 30,962
  • 25
  • 85
  • 135
Artem Fedotov
  • 432
  • 1
  • 6
  • 21