title: Using webpack to use require modules in browser
body: <p>Tried for the past 2 days to use require('modules') in the browser with webpack, when I could do the same thing in browserify in 5 minutes...</p>
  
  <p>Here's my <strong>webpack.config.js</strong></p>
  
  <pre><code>var webpack = require('webpack');
  var path = require('path');
  var fs = require('fs');
  
  var nodeModules = {};
  fs.readdirSync('node_modules')
    .filter(function(x) {
      return ['.bin'].indexOf(x) === -1;
    })
    .forEach(function(mod) {
      nodeModules[mod] = 'commonjs ' + mod;
    });
  
  module.exports = {
      entry: "./main.js",
      output: {
          filename: "bundle.js"
      }
  }
  </code></pre>
  
  <p>However, no matter what I do I get some sort of error. Currently I am getting: </p>
  
  <pre><code>bundle.js:390 Uncaught Error: Cannot find module "net"
  </code></pre>
  
  <p>and when I run webpack it throws these errors: <a href="http://pastebin.com/RgFN3uYm" rel="noreferrer">http://pastebin.com/RgFN3uYm</a></p>
  
  <p>I followed <a href="https://webpack.github.io/docs/tutorials/getting-started/" rel="noreferrer">https://webpack.github.io/docs/tutorials/getting-started/</a> and <a href="http://www.pauleveritt.org/articles/pylyglot/webpack/" rel="noreferrer">http://www.pauleveritt.org/articles/pylyglot/webpack/</a> yet I still get these errors. </p>
  
  <p>I've tried to run it with this: <code>webpack ./main.js -o bundle.js</code> Yet it still doesn't work. </p>
  
  <p><strong>How can this be resolved?</strong></p>