title: How to build a ES6 express app with webpack 2 and babel?
body: <p>Given the following <strong>Webpack 2</strong> configuration, I want to write a express app using ES6. My <code>.babelrc</code> has only the <code>es2015</code> preset:</p>
  
  <pre><code>const path = require('path');
  
  module.exports = {
    target: 'node',
  
    entry: path.resolve(__dirname, 'src', 'server.js'),
  
    output: {
      path: path.resolve(__dirname, 'dist'),
      filename: 'server.bundle.js',
    },
  
    module: {
      loaders: [
        {
          test: /\.js$/,
          exclude: /node_modules/,
          use: 'babel-loader',
        },
      ],
    },
  };
  </code></pre>
  
  <p>Running webpack and starting the server work fine, but when accessing the URL through the browser I get the following error:</p>
  
  <pre><code>Error: Cannot find module "."
      at webpackMissingModule (/Users/Me/project/dist/server.bundle.js:18208:74)
  </code></pre>
  
  <p>I don't know whether it's due to the <code>.</code> in a <code>require('./some/other/file')</code> call (not all files are ES6, so these one use <code>require()</code> instead of <code>import</code>);  or maybe some configuration I'm missing.</p>
  
  <p>And also, given that stack trace I can't really map it to the original source file.</p>
  
  <p>Thanks in advance</p>
  
  <p><strong>Update 1</strong></p>
  
  <p>I just realize I'm trying to use webpack to transpile ES6 code because I'm trying to replicate another build task (the one in <a href="http://mern.io" rel="nofollow noreferrer">mern.io</a>), but I could do the same just with babel. Maybe there's no reason for using webpack on the serverside.</p>