Module not found: Error: Can't resolve 'fs' using webpack and Electron

Jan 7 2018

Module not found: Error: Can't resolve 'fs'

If you’ve set up webpack with an Electron application and you hit this strange error when trying to bundle your project, you’ve probably forgotten to include the target in your webpack config. This is easily fixed by editing webpack.config.js to include the target, something like this:

const path = require('path');

module.exports = {
  entry: './app.js',
  output: {
    filename: 'bundle.js'
  },
  target: 'electron'
  .
  .
  .
}