title: Unexpected token: io.listen(server)
body: <p>I am new to <code>node.js</code>. Following some of the tutorials, I created a file named <code>server.js</code> and put this code in that file:</p>
  
  <pre><code>var http = require("http");
  var url = require('url');
  var fs = require('fs');
  
  var server = http.createServer(function(request, response){
      console.log('Connection');
      var path = url.parse(request.url).pathname;
   console.log(path);
      switch(path){
          case '/':
              response.writeHead(200, {'Content-Type': 'text/html'});
              response.write('hello world');
              break;
          case '/socket.html':
      response.writeHead(200, {'Content-Type': 'text/html'});
              response.write('Inside hello world');
              fs.readFile(__dirname + path, function(error, data){
                  if (error){
                      response.writeHead(404);
                      response.write("opps this doesn't exist - 403");
                  }
                  else{
                      response.writeHead(200, {"Content-Type": "text/html"});
                      response.write(data, "utf8");
                  }
              });
              break;
          default:
              response.writeHead(404);
              response.write("opps this doesn't exist - 405");
              break;
      }
      response.end();
  });
  
  server.listen(8001);
  
  var io.listen(server);
  </code></pre>
  
  <p>Then I run this using the command: <code>node C:\Users\user\Desktop\server.js</code> and I get this error:</p>
  
  <pre><code>C:\Users\user\Desktop\server.js:38
  var io.listen(server);
    ^
  SyntaxError: Unexpected token .
  at Module._compile (module.js:439:25)
  at Object.Module._extensions..js (module.js:474:10)
  at Module.load (module.js:356:32)
  at Function.Module._load (module.js:312:12)
  at Function.Module.runMain (module.js:497:10)
  at startup (node.js:119:16)
  at node.js:906:3
  </code></pre>
  
  <p>This line is causing the error:</p>
  
  <p><code>var io.listen(server);</code></p>
  
  <p>Initially I thought of installing the <code>npm</code> package <code>socket.io</code> hence I tried this:</p>
  
  <p><code>npm install --save socket.io</code></p>
  
  <p>But after this also I am getting the same error:</p>
  
  <pre><code>C:\Users\user\Desktop\server.js:38
  var io.listen(server);
    ^
  SyntaxError: Unexpected token .
  at Module._compile (module.js:439:25)
  at Object.Module._extensions..js (module.js:474:10)
  at Module.load (module.js:356:32)
  at Function.Module._load (module.js:312:12)
  at Function.Module.runMain (module.js:497:10)
  at startup (node.js:119:16)
  at node.js:906:3
  </code></pre>
  
  <p>Please advice how to resolve this error.</p>