title: TypeError: require(...) is not a function in node js
body: <p>I am trying to learn node js and trying few sample code, and when I come across the socket.io website, I tried the sample code in their website. I don't think the code written on their website will be wrong. The error which I'm getting while I'm running the code, I don't know how to solve it, I don't know where I have done wrong. I'm very new to node js, please help me. This is the link of
  <a href="http://socket.io/get-started/chat/" rel="nofollow">website</a>
   which I taken the code. </p>
  
  <p>And this is code which I'm trying to run.</p>
  
  <pre><code>var app = require('express')();
  var http = require('http').Server(app);
  var io = require('socket.io')(http);
  
  app.get('/', function(req, res){
  res.sendfile('index.html');
  });
  
  io.on('connection', function(socket){
  console.log('a user connected');
  });
  
  http.listen(3000, function(){
  console.log('listening on *:3000');
   });
  </code></pre>
  
  <p>And the error I'm getting while running the code is</p>
  
  <pre><code>var io = require('socket.io')(http);                                                                                                               
                           ^                    
  TypeError: require(...) is not a function                                                                                                          
  at Object.&lt;anonymous&gt; (/home/ubuntu/workspace/index.js:3:30)                                                                                   
  at Module._compile (module.js:434:26)                                                                                                          
  at Object.Module._extensions..js (module.js:452:10)                                                                                            
  at Module.load (module.js:355:32)                                                                                                              
  at Function.Module._load (module.js:310:12)                                                                                                    
  at Module.runMain [as _onTimeout] (module.js:475:10)                                                                                           
  at Timer.listOnTimeout (timers.js:89:15)
  </code></pre>