title: Module not found: Error: Can't resolve 'fs' with webpack
body: <p>I produced a small code for building by webpack. The source entry file is like:</p>
  <pre><code>import archiver from 'archiver'
  import request from 'request'
  import mkdirp from 'mkdirp'
  import Zip from 'node-zip'
  import Zlib from 'zlib'
  import path from 'path'
  import fs from 'fs'
  
  export default class myTestClass {
  
  
     constructor (config) {
  
      super (config)
  
     }
  
    //......
  }
  </code></pre>
  <p>The webpack config is:</p>
  <pre><code>var webpack = require('webpack');
  var path = require('path')
  
  
  module.exports = {
      entry: [
          path.resolve(&quot;./js/app.js&quot;) 
    ],
     output: {
        path: path.resolve('./build'),
        filename: &quot;build.js&quot;
    }, 
    module: {
       loaders: [
          { test: /\.css$/, loader: 'style-loader!css-loader' },
  
          { test: /\.scss$/, loader: 'style!css!sass?sourceMap'},
          { test: /\.(png|jpg)$/, loader: 'url-loader?limit=8192'},
          { test: /\.json$/, loader: 'json-loader' },
          { test: /\.js$/,
              exclude: /node_modules/,
              loader: 'babel-loader',
              query: {
                presets: ['es2015'],
                plugins: ['transform-runtime']
              }
          } 
          
      ]
      
  },
  
  resolve: {
      modules: [
        &quot;./js&quot;, 
        &quot;./node_modules&quot;
      ],
      extensions : ['.js', '.jsx', '.json']
    },
    resolveLoader: {
      modules: ['node_modules']
    },
    node: {
      console: true
   },
   plugins: [
    new webpack.NoEmitOnErrorsPlugin(),
    new webpack.ProvidePlugin({
      'window.jQuery': 'jquery',
      Promise: 'bluebird',
      jQuery: 'jquery',
      $: 'jquery'
    })
   ]
  };
  </code></pre>
  <p>The main app.js simply calls myTestClass:</p>
  <pre><code>import MyClass from './myTestClass.js'
  
  module.exports = async function() {
    
   const myCls = new MyClass();
  
  return '';
  }; 
  </code></pre>
  <p>Running webpack, I got many same errors:</p>
  <pre><code>Module not found: Error: Can't resolve 'fs'
  </code></pre>
  <p>If I followed the comment in <a href="https://github.com/webpack-contrib/css-loader/issues/447" rel="nofollow noreferrer">https://github.com/webpack-contrib/css-loader/issues/447</a> , i.e.</p>
  <pre><code>node:{
     fs:'empty'
   }
  </code></pre>
  <p>It can be built, but when running the code on client, an error will pop out from the build.js. The error is: fs is undefined. I think this is because fs of node is set to empty.</p>
  <pre><code>var fs$ReadStream = fs.ReadStream
  ReadStream.prototype = Object.create(fs$ReadStream.prototype)
  ReadStream.prototype.open = ReadStream$open
  </code></pre>
  <p>Could you shed a light how to solve this issue? is that a correct usage to set fs = empty? IF it is correct, what issue with the build.js?</p>