title: nodejs server app having type errors like path.join
body: <p>As i am running my server.js ,it starts of pretty well with the main staring page being loaded up but there i have to enter a nickname to enter any room. As i enter the name and click on the Create chat room button it shows this type of error. Since i am new to building node.js apps ,please help me to solve this issue..The server code is provided below..</p>
  
  <pre><code>TypeError: Arguments to path.join must be strings
          at path.js:360:15
          at Array.filter (native)
          at exports.join (path.js:358:36)
          at exports.send (/home/gauz/Desktop/hackview-master/node_modules/connect/lib/middleware/static.js:129:20)
          at ServerResponse.res.sendfile (/home/gauz/Desktop/hackview-master/node_modules/express/lib/response.js:186:3)
          at app.get.req.session.nick (/home/gauz/Desktop/hackview-master/server.js:71:9)
          at callbacks (/home/gauz/Desktop/hackview-master/node_modules/express/lib/router/index.js:272:11)
          at param (/home/gauz/Desktop/hackview-master/node_modules/express/lib/router/index.js:246:11)
          at param (/home/gauz/Desktop/hackview-master/node_modules/express/lib/router/index.js:243:11)
          at pass (/home/gauz/Desktop/hackview-master/node_modules/express/lib/router/index.js:253:5)
          at Router._dispatch (/home/gauz/Desktop/hackview-master/node_modules/express/lib/router/index.js:280:5)
          at Object.Router.middleware [as handle] (/home/gauz/Desktop/hackview-master/node_modules/express/lib/router/index.js:45:10)
          at next (/home/gauz/Desktop/hackview-master/node_modules/connect/lib/http.js:204:15)
          at next (/home/gauz/Desktop/hackview-master/node_modules/connect/lib/middleware/session.js:322:9)
          at /home/gauz/Desktop/hackview-master/node_modules/connect/lib/middleware/session.js:341:9
          at /home/gauz/Desktop/hackview-master/node_modules/connect/lib/middleware/session/memory.js:52:9
          at process._tickCallback (node.js:415:13)
  </code></pre>
  
  <p><strong>Server Code:</strong></p>
  
  <pre><code>var express=require('express'),
      app = express.createServer(),
      sharejs = require('share'),
      sharejsOptions={db:{type:'none'}};
  /*
  var express=require('express');
  var app = express();
  var sharejs = require('share');
  var sharejsOptions={db:{type:'none'}};
  */
  var env = process.env.NODE_ENV;
  
  //if we were provided redis options, use them for persistence
  //the if case is for developers not using redis
  if(process.env.redis_port){
      sharejsOptions.db= {
          type: 'redis',
          prefix: '',
          port: process.env.redis_port,
          auth: process.env.redis_auth || null
      }
  };
  
  sharejs.server.attach(app, sharejsOptions);//attach to express
  
  if (env !== 'production')
    app.use(express.logger('dev'));
  
  app.use(express.static(__dirname + '/public'));
  app.use(express.favicon(__dirname+"/public/favicon.ico"));
  app.use(express.cookieParser());
  app.use(express.session({secret:"SuperSecretSessionKey"}));
  
  //heroku support
  var port = process.env.PORT || 8000;
  app.listen(port);
  console.log('App running on port : '+port);
  
  //webRTC Stuff
  var webRTC = require('webrtc.io').listen(app);
  require('./rtc.js')(webRTC);
  
  app.get('/', function(req, res) {
    res.sendfile(__dirname + '/public/room.html');
  });
  
  /** Create a new random room */
  app.get('/join',function(req,res){
    var roomName=req.query.nickname.split('@')[1];
    if(!roomName)
      roomName=getRandomRoom();
    var nickName = req.query.nickname.split('@')[0];
    req.session.nick = nickName;
    res.redirect('/room/'+roomName);
  });
  
  var getRandomRoom = function(){
    var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
    var string_length = 8;
    var randomstring = '';
    for (var i=0; i&lt;string_length; i++) {
      var rnum = Math.floor(Math.random() * chars.length);
      randomstring += chars.substring(rnum,rnum+1);
    }
    return randomstring;
  }
  
  app.get('/room/:roomName',function(req,res){
    if(req.session.nick || req.query.asknick){
      //if a person has his nickname set, let him reach that
      res.sendfile(__dirname+'/public/room.html');
    }
    else{
      //make sure he/she is asked a username
      res.redirect('/room/'+req.params.roomName+'?asknick=yes');
    }
  });
  
  app.get('/setnick',function(req,res){
    res.cookie('nick',req.query.nick);
    req.session.nick = req.query.nick;
    res.send('');
  });
  
  app.get('/debug',function(req,res){
    res.json(req.session);
  });
  </code></pre>