title: Node.js scope error
body: <p>I'm getting the following error :</p>
  
  <pre><code>/Users/nblavoie/Desktop/HotPie/HotPie/apps/authentication/routes.coffee:6
    app.get('/login', function(req, res) {
    ^
  ReferenceError: app is not defined
      at Object.&lt;anonymous&gt; (/Users/nblavoie/Desktop/HotPie/HotPie/apps/authentication/routes.coffee:6:3)
      at Object.&lt;anonymous&gt; (/Users/nblavoie/Desktop/HotPie/HotPie/apps/authentication/routes.coffee:15:4)
      at Module._compile (module.js:449:26)
      at Object.require.extensions..coffee (/Users/nblavoie/Desktop/HotPie/HotPie/node_modules/coffee-script/lib/coffee-script/coffee-script.js:22:21)
      at Module.load (module.js:356:32)
      at Function.Module._load (module.js:312:12)
      at Module.require (module.js:362:17)
      at require (module.js:378:17)
      at Object.&lt;anonymous&gt; (/Users/nblavoie/Desktop/HotPie/HotPie/app.js:31:1)
      at Module._compile (module.js:449:26)
  </code></pre>
  
  <p>While trying to pass the (app) variable to the following require :</p>
  
  <pre><code>/**
   * Module dependencies.
   */
  
  require('coffee-script');
  
  var express = require('express')
    , http = require('http')
    , path = require('path');
  
  var app = express();
  
  app.configure(function(){
    app.set('port', process.env.PORT || 3000);
    app.set('views', __dirname + '/views');
    app.set('view engine', 'jade');
    app.use(express.favicon());
    app.use(express.logger('dev'));
    app.use(express.bodyParser());
    app.use(express.methodOverride());
    app.use(app.router);
    app.use(express.static(path.join(__dirname, 'public')));
  });
  
  app.configure('development', function(){
    app.use(express.errorHandler());
  });
  
  // Routes
  **require('./apps/authentication/routes')(app);**
  
  http.createServer(app).listen(app.get('port'), function(){
    console.log("Express server listening on port " + app.get('port'));
  });
  </code></pre>
  
  <p>Using the app variable in the following file :</p>
  
  <pre><code>routes = (app) -&gt; 
  app.get '/login', (req, res) -&gt;
      res.render 'views/login',
          title: 'Login'
          stylesheet: 'login'
  module.exports = routes
  </code></pre>
  
  <p>I know that the variable scope is different from one JS file to another. But why does the following line :</p>
  
  <pre><code>require('./apps/authentication/routes')(app);
  </code></pre>
  
  <p>Doesn't pass the app variable?</p>