Cannot find entry module in webpack using nodejs API
<p>I am trying to run webpack from within nodejs. My directory structure looks like this:</p>

<pre><code>build
|- dev.js
dist
|- bundle.js
src
|- layout
   |- App.js
|- server
   |- app.js
</code></pre>

<p>dev.js:</p>

<pre><code>const webpack = require('webpack');
const path = require('path');

// returns a Compiler instance
const compiler = webpack(
  {
    context: path.resolve(__dirname, '../src'),
    entry: [
      './server/app.js'
    ],
    output: {
      path: path.join(__dirname, '../dist'),
      filename: 'bundle.js'
    },
    module: {
      loaders: [
        {
          test: /\.js$/,
          exclude: /node_modules/,
          loader: 'babel-loader?presets[]=es2015&amp;presets[]=react'
        }
      ]
    }
  }
);

compiler.run(function(err, stats) {
  if(err) {
    console.log('Err');
  }
});
</code></pre>

<p>app.js:</p>

<pre><code>import express from 'express';

import React from 'react';
import { renderToString } from 'react-dom/server';

import App from '../layout/App';
const app = express();

app.get('*', (req, res) =&gt; {
  res.send(renderToString(&lt;App /&gt;));
});


app.listen(3000, () =&gt; {
});
</code></pre>

<p>If I now run <code>node build/dev.js</code> it generates my bundle.js, but it does not find my entry module.</p>

<pre><code>(function webpackMissingModule() { throw new Error("Cannot find module \"./server/app.js\""); }());
</code></pre>

<p>Even though I think this is how the entry point should be defined, I have tried many combinations, even the absolute path. But always the same result, it cannot find the entry module. What am I missing here?</p>