3

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?

3
  • Could you try writing module.exports = { modify: config => { config.node = { fs: "empty" }; return config; } }; in your razzle.config.js file instead?
    – Tholle
    Jul 16, 2018 at 21:56
  • 1
    Great, that worked for me! thank you
    – Faye Hayes
    Jul 17, 2018 at 0:13
  • Awesome! You're welcome.
    – Tholle
    Jul 17, 2018 at 0:17

1 Answer 1

4

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;
  }
};
1
  • @FayeHayes Great! Happy to help.
    – Tholle
    Jul 17, 2018 at 14:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.