title: NodeJS throw new TypeError
body: <p>When i try to run my JS file i get this error:</p>
  
  <pre><code>http.js:783
      throw new TypeError('first argument must be a string or Buffer');
  </code></pre>
  
  <p>I was following this tutorial which didn't seem to mention the problem <a href="http://arminboss.de/blog/2013/tutorial-how-to-create-a-basic-chat-with-node-js/" rel="nofollow">Tutorial Link</a></p>
  
  <p>My JS file has:</p>
  
  <pre><code>var http = require('http'),
      fs = require('fs'),
      sanitize = require('validator').sanitize;
  
  var app = http.createServer(function (request, response) {
      fs.readFile("client.html", 'utf-8', function (error, data) {
          response.writeHead(200, {'Content-Type': 'text/html'});
          response.write(data);
          response.end();
      });
  }).listen(1337);
  
  var io = require('socket.io').listen(app);
  
  io.sockets.on('connection', function(socket) { 
      socket.on('message_to_server', function(data) { 
          var escaped_message = sanitize(data["message"]).escape();
          io.sockets.emit("message_to_client",{ message: escaped_message }); 
      });
  });
  </code></pre>
  
  <p>I have Socket.io and validator installed in my node_modules folder. I'm quite new to this sort of stuff and looks like this tutorial wasn't a good starting choice, I can't seem to get it working. </p>