title: Runtime error using socket.io in typescript bundled by webpack
body: <p>I was trying to make use of web-sockets via socket.io in a typescript written node server with expressjs. Bundled with webpack.</p>
  
  <p>The server code Looks as follow:</p>
  
  <pre><code>import * as Express from "express";
  import * as SocketIO from "socket.io";
  import * as Http from "http";
  
  const app = Express();
  
  app.get("/", (reqest: Express.Request, response: Express.Response) =&gt; {
      response.sendFile(process.cwd() + "/dist/index.html");
  });
  
  app.use(Express.static("./dist/"));
  
  const server = app.listen(3210, () =&gt; {
      console.log("Listening to port 3210");
  });
  
  const io = SocketIO.listen(server);
  </code></pre>
  
  <p>The last line causes the issues mentioned later.</p>
  
  <p>The coresponding <code>webpack.config.js</code>:</p>
  
  <pre><code>module.exports = [
      {
          entry: "./server/main.ts",
          output: {
              path: "./dist",
              filename: "server.js"
          },
          debug: true,
          devtool: "source-map",
          module: {
              loaders: [
                  {
                      test: /\.ts$/,
                      loader: "ts-loader"
                  }
                  , {
                      test: /\.json/,
                      loader: "json-loader"
                  }
              ]
          },
          target: "node",
          node: {
              fs: "empty",
              net: "empty"
          }
          ts: {
              configFileName: 'server.tsconfig.json'
          }
      }
  ];
  </code></pre>
  
  <p>But at the end <code>webpack</code> prints out the following warnings:</p>
  
  <blockquote>
    <p>WARNING in ./~/express/lib/view.js</p>
    
    <p>Critical dependencies:</p>
    
    <p>78:29-56 the request of a dependency is an expression</p>
    
    <p>@ ./~/express/lib/view.js 78:29-56</p>
    
    <p>WARNING in ./~/socket.io/~/engine.io/lib/server.js</p>
    
    <p>Critical dependencies:</p>
    
    <p>75:43-65 the request of a dependency is an expression</p>
    
    <p>@ ./~/socket.io/~/engine.io/lib/server.js 75:43-65</p>
    
    <p>WARNING in ./~/socket.io/~/engine.io/~/ws/lib/Validation.js</p>
    
    <p>Module not found: Error: Cannot resolve module 'utf-8-validate' in ...\node_modules\socket.io\node_modules\engine.io\node_modules\ws\lib</p>
    
    <p>@ ./~/socket.io/~/engine.io/~/ws/lib/Validation.js 10:19-44</p>
    
    <p>WARNING in ./~/socket.io/~/engine.io/~/ws/lib/BufferUtil.js</p>
    
    <p>Module not found: Error: Cannot resolve module 'bufferutil' in ...\node_modules\socket.io\node_modules\engine.io\node_modules\ws\lib</p>
    
    <p>@ ./~/socket.io/~/engine.io/~/ws/lib/BufferUtil.js 10:19-40</p>
    
    <p>WARNING in ./~/socket.io/~/socket.io-client/~/engine.io-client/~/ws/lib/Validation.js</p>
    
    <p>Module not found: Error: Cannot resolve module 'utf-8-validate' in ...\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\lib</p>
    
    <p>@ ./~/socket.io/~/socket.io-client/~/engine.io-client/~/ws/lib/Validation.js 10:19-44</p>
    
    <p>WARNING in ./~/socket.io/~/socket.io-client/~/engine.io-client/~/ws/lib/BufferUtil.js</p>
    
    <p>Module not found: Error: Cannot resolve module 'bufferutil' in ...\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\lib</p>
    
    <p>@ ./~/socket.io/~/socket.io-client/~/engine.io-client/~/ws/lib/BufferUtil.js 10:19-40</p>
    
    <p>Process terminated with code 0.</p>
  </blockquote>
  
  <p>Running server.js results in:</p>
  
  <blockquote>
    <p>fs.js:549 return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);</p>
    
    <p>TypeError: path must be a string</p>
    
    <p>....</p>
  </blockquote>
  
  <p>Does anyone know what I did wrong?</p>