Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

razzle Can't resolve 'fs' / 'net' (server side rendering react app)

Currently using https://github.com/jaredpalmer/razzle to implement SSR of a React Application. Running into the following errors within my node modules:

ERROR: Can't resolve 'fs'

AND THIS

ERROR: Can't resolve 'net'

I've added a razzle.config.js to customize the razzle config to look like this(below) and the code is still not running.

module.exports = {
  target: 'node',
  node: {
    console: 'empty',
    fs: 'empty',
    net: 'empty',
    tls: 'empty'
  }
};

Any idea as to why I'm receiving the errors and what I can do to fix?

like image 724
Faye Hayes Avatar asked Nov 19 '25 21:11

Faye Hayes


1 Answers

If you want to extend the Webpack config, you need to use the modify function of the razzle.config.js export.

Example

module.exports = {
  modify: config => {
    config.node = { fs: "empty" };
    return config;
  }
};
like image 102
Tholle Avatar answered Nov 22 '25 14:11

Tholle



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!