title: Coffee script compiler keeps on throwing error 'TypeError: Cannot read property '2' of undefined'
body: <p>I'm relatively new to coffee script.
  Currently, when compiling a piece of coffee script (<code>coffee -c app.coffee</code>), I receive the following error (See below) even though '2' is nowhere in my code. Why is this happening and how do I fix this?</p>
  
  <p>Here is the error:</p>
  
  <pre><code>`TypeError: Cannot read property '2' of undefined
      at Lexer.exports.Lexer.Lexer.tokenize (/usr/lib/node_modules/coffee script/lib/coffee-script/lexer.js:43:52)
      at Object.&lt;anonymous&gt; (/usr/lib/node_modules/coffee-script/lib/coffee-script/coffee-script.js:52:20)
      at Object.compile (/usr/lib/node_modules/coffee-script/lib/coffee-script/coffee-script.js:34:19)
      at compileScript (/usr/lib/node_modules/coffee-script/lib/coffee-script/command.js:232:33)
      at compilePath (/usr/lib/node_modules/coffee-script/lib/coffee-script/command.js:174:14)
      at Object.exports.run (/usr/lib/node_modules/coffee-script/lib/coffee-script/command.js:98:20)
      at Object.&lt;anonymous&gt; (/usr/lib/node_modules/coffee-script/bin/coffee:7:41)
      at Module._compile (module.js:456:26)
      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:935:3`
  </code></pre>
  
  <p>Here is my code:</p>
  
  <pre><code> express = require 'express'   
   path = require 'path'   
   favicon = require 'serve-favicon'   
   logger = require 'morgan'   
   cookieParser = require 'cookie-parser'   
   bodyParser = require 'body-parser'   
   clicolour = require 'cli-color'   
   fs = require "fs"   
   morgan = require "morgan"   
  
   passport = require 'passport'   
   passportlocal = require 'passport-local'   
   passporthttp = require 'passport-http'   
  
   mongoose = require 'mongoose'   
   MongoClient = require 'mongodb' .MongoClient  
   assert = require 'assert'   
   ObjectId = require 'mongodb'.ObjectID  
  
   connect = require "./libs/connect.js"   
   passportconfig = require "./libs/passport.js"   
   # wlogger = require "./libs/wlogger.js"   
   #  debuge = require "./libs/debug.js"   
   wlogger = require "./libs/logger"   
  
   routes = require './routes/index'   
   users = require './routes/users'   
  
   #debug = require 'debug'   'Web-OS:server'   
   http = require 'http'   
   https = require 'https'   
  
   app = express     
  
   bcrypt = require 'bcryptjs'   
   salt = bcrypt.genSaltSync(10)   
  
   logFile = fs.createWriteStream('./logs/wos.log', {flags: 'a'})    
  
   # view engine setup
  app.set('views', path.join(__dirname, 'views'));
  app.set('view engine', 'jade');
  app.set('view engine', 'ejs');
  
   # uncomment after placing your favicon in /public
   #app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
  app.use(logger('dev'));
  app.use(bodyParser.json());
  app.use(bodyParser.urlencoded({ extended: false }));
  app.use(cookieParser());
  app.use(express.static(path.join(__dirname, 'public')));
  app.use(express.static(path.join(__dirname, 'bower_components')));
  app.use(express.static(path.join(__dirname, 'views')));
  app.use(logger({stream: logFile}));
  app.use(logger('stream', wlogger.logger));
  #app.use(require('morgan')({ "stream": wlogger.stream }));
  wlogger.debug("Overriding 'Express' logger");
  app.use(require("morgan")("combined", { "stream": wlogger.stream }));
  
  
   userSchema = new mongoose.Schema -&gt;
    username: { type: String }
  , email: String
  , pwd: String
  
   exits = false  
   suser = mongoose.model('usersc', userSchema)   
  
  app.use('/', routes)   
  app.use('/users', users)  
  app.use('passportconfig', passportconfig)   
  
  # Setup HTTPS
  # uncommitted after finding way to get certs
  # options = {
    #key: fs.readFileSync  path.join  __dirname, 'cert/Web-OS-PRIVATE.key'  
    # This certificate should be a bundle containing your server certificate and any intermediates
    # cat certs/cert.pem certs/chain.pem &gt; certs/server-bundle.pem
  #, cert: fs.readFileSync  path.join  __dirname, 'cert/Web-OS-SIGNED.crt'  
    # ca only needs to be specified for peer-certificates
  #, ca: [ fs.readFileSync  path.join  caCertsPath, 'my-root-ca.crt.pem'   ]
  #, requestCert: false
  #, rejectUnauthorized: true
  #}  
  
  
  
   port = process.env.PORT || 8080  
  
  app.listen(port, () -&gt;
      clicolour.cyanBright  "webOS "  + clicolour.yellowBright  "startup "  + "Running on port " + port   
      clicolour.cyanBright  "webOS "  + clicolour.yellowBright  "startup "  + "The date and time is:", Date      
    clicolour.cyanBright  "webOS "  + clicolour.yellowBright  "startup "  + connect.connect  "Connect"    
  
  )    
  # HTTPS
  httpsserver = https.createServer  options   
  # Turn on HTTPS
  # httpsserver.on  'request', app   
     # httpsserver.listen  6060, function     {
       #  console.log  clicolour.cyanBright  "webOS "  + clicolour.yellowBright  "HTTPS "  + "HTTPS Server Started " + port   
      #    console.log  clicolour.cyanBright  "webOS "  + clicolour.yellowBright  "HTTPS "  + "The date and time is:", Date      
      #onListening   
      #}    
  
  
  
  app.on('error', onError())   
  app.on('listening', onListening())   
  
  normalizePort = (val) -&gt;
     port = parseInt(val, 10)   
  
    if isNaN(port)
      # named pipe
      return val  
  
    if port &gt;= 0  
      # port number
      return port  
  
    return false  
  
  #
   # Event listener for HTTP server "error" event.
   #
  
  onError = (error) -&gt;
    if error.syscall !== 'listen'
      throw error  
  
  
     bind = typeof port === 'string'
      ? 'Pipe ' + port
      : 'Port ' + port  
  
    # handle specific listen errors with friendly messages
    switch error.code  -&gt;
      when 'EACCES' then
        console.error(bind + ' requires elevated privileges')   
        process.exit(1)   
        break  
      when 'EADDRINUSE' then
        console.error(bind + ' is already in use')   
        process.exit(1)   
        break  
      else
        throw error  
  
  
   # Event listener for HTTP server "listening" event.
  
  onListening = () -&gt;
     addr = httpsserver.address     
     bind = typeof addr === 'string'
      ? 'pipe ' + addr
      : 'port ' + addr.port  
    wlogger.debug('Listening on ' + bind)   
  
  
  
  # catch 404 and forward to error handler
  app.use((req, res, next) -&gt;
     err = new Error  'Not Found'   
    err.status = 404  
    next  err   
  )   
  
  app.post('/login', (req, res)  -&gt;
     # passportlocal.authenticate  'local'   
    res.redirect('/')  
  )   
  
  # error handlers
  
  # development error handler
  # will print stacktrace
  if app.get('env'  === 'development')
    app.use((err, req, res, next) -&gt;
      res.status(err.status || 500)   
      res.render('error.jade', {
        message: err.message,
        error: err
      })   
    )   
  
  
  # production error handler
  # no stacktraces leaked to user
  app.use((err, req, res, next) -&gt;
    res.status(err.status || 500)   
    res.render('error.jade', {
      message: err.message,
      error: {}
    })   
  )`
  </code></pre>
  
  <p>In case it helps, I made this code by taking the JavaScript version of this and adjusting it to be coffee script.</p>
  
  <p>Here is the JavaScript I adjusted to be coffee-script:</p>
  
  <pre><code>var express = require('express');
  var path = require('path');
  var favicon = require('serve-favicon');
  var logger = require('morgan');
  var cookieParser = require('cookie-parser');
  var bodyParser = require('body-parser');
  var clicolour = require('cli-color');
  var fs = require("fs");
  var morgan = require("morgan");
  
  var passport = require('passport');
  var passportlocal = require('passport-local');
  var passporthttp = require('passport-http');
  
  var mongoose = require('mongoose');
  var MongoClient = require('mongodb').MongoClient;
  var assert = require('assert');
  var ObjectId = require('mongodb').ObjectID;
  
  var connect = require("./libs/connect.js");
  var passportconfig = require("./libs/passport.js");
  //var wlogger = require("./libs/wlogger.js");
  // var debuge = require("./libs/debug.js");
  var wlogger = require("./libs/logger");
  
  var routes = require('./routes/index');
  var users = require('./routes/users');
  
  var debug = require('debug')('Web-OS:server');
  var http = require('http');
  var https = require('https');
  
  var app = express();
  
  var bcrypt = require('bcryptjs');
  var salt = bcrypt.genSaltSync(10); 
  
  var logFile = fs.createWriteStream('./logs/wos.log', {flags: 'a'});
  
  
  // view engine setup
  app.set('views', path.join(__dirname, 'views'));
  app.set('view engine', 'jade');
  app.set('view engine', 'ejs');
  
  // uncomment after placing your favicon in /public
  //app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
  app.use(logger('dev'));
  app.use(bodyParser.json());
  app.use(bodyParser.urlencoded({ extended: false }));
  app.use(cookieParser());
  app.use(express.static(path.join(__dirname, 'public')));
  app.use(express.static(path.join(__dirname, 'bower_components')));
  app.use(express.static(path.join(__dirname, 'views')));
  app.use(logger({stream: logFile}));
  app.use(logger('stream', wlogger.logger));
  //app.use(require('morgan')({ "stream": wlogger.stream }));
  wlogger.debug("Overriding 'Express' logger");
  app.use(require("morgan")("combined", { "stream": wlogger.stream }));
  
  var userSchema = new mongoose.Schema({
    username: { type: String }
  , email: String
  , pwd: String
  });
  var exits = false;
  var suser = mongoose.model('usersc', userSchema);
  
  app.use('/', routes);
  app.use('/users', users);
  app.use('passportconfig', passportconfig);
  
  // Setup HTTPS
  // uncommitted after finding way to get certs
  /** options = {
    key: fs.readFileSync(path.join(__dirname, 'cert/Web-OS-PRIVATE.key'))
    // This certificate should be a bundle containing your server certificate and any intermediates
    // cat certs/cert.pem certs/chain.pem &gt; certs/server-bundle.pem
  , cert: fs.readFileSync(path.join(__dirname, 'cert/Web-OS-SIGNED.crt'))
    // ca only needs to be specified for peer-certificates
  //, ca: [ fs.readFileSync(path.join(caCertsPath, 'my-root-ca.crt.pem')) ]
  , requestCert: false
  , rejectUnauthorized: true
  }; */
  
  
  
  var port = process.env.PORT || 8080;
  
  app.listen(port, function () {
      console.log(clicolour.cyanBright("webOS ") + clicolour.yellowBright("startup ") + "Running on port " + port);
      console.log(clicolour.cyanBright("webOS ") + clicolour.yellowBright("startup ") + "The date and time is:", Date());
    console.log(clicolour.cyanBright("webOS ") + clicolour.yellowBright("startup ") + connect.connect("Connect"));
  
  } );
  // HTTPS
  httpsserver = https.createServer(options);
  // Turn on HTTPS
  /** httpsserver.on('request', app);
      httpsserver.listen(6060, function () {
         console.log(clicolour.cyanBright("webOS ") + clicolour.yellowBright("HTTPS ") + "HTTPS Server Started " + port);
          console.log(clicolour.cyanBright("webOS ") + clicolour.yellowBright("HTTPS ") + "The date and time is:", Date());
      onListening()
      }); */
  
  
  
  app.on('error', onError);
  app.on('listening', onListening);
  
  function normalizePort(val) {
    var port = parseInt(val, 10);
  
    if (isNaN(port)) {
      // named pipe
      return val;
    }
  
    if (port &gt;= 0) {
      // port number
      return port;
    }
  
    return false;
  }
  
  /**
   * Event listener for HTTP server "error" event.
   */
  
  function onError(error) {
    if (error.syscall !== 'listen') {
      throw error;
    }
  
    var bind = typeof port === 'string'
      ? 'Pipe ' + port
      : 'Port ' + port;
  
    // handle specific listen errors with friendly messages
    switch (error.code) {
      case 'EACCES':
        console.error(bind + ' requires elevated privileges');
        process.exit(1);
        break;
      case 'EADDRINUSE':
        console.error(bind + ' is already in use');
        process.exit(1);
        break;
      default:
        throw error;
    }
  }
  
  /**
   * Event listener for HTTP server "listening" event.
   */
  
  function onListening() {
    var addr = httpsserver.address();
    var bind = typeof addr === 'string'
      ? 'pipe ' + addr
      : 'port ' + addr.port;
    wlogger.debug('Listening on ' + bind);
  }
  
  
  // catch 404 and forward to error handler
  app.use(function(req, res, next) {
    var err = new Error('Not Found');
    err.status = 404;
    next(err);
  });
  
  app.post('/login', function(req, res) {
     // passportlocal.authenticate('local');
    res.redirect('/');
  });
  
  // error handlers
  
  // development error handler
  // will print stacktrace
  if (app.get('env') === 'development') {
    app.use(function(err, req, res, next) {
      res.status(err.status || 500);
      res.render('error.jade', {
        message: err.message,
        error: err
      });
    });
  }
  
  // production error handler
  // no stacktraces leaked to user
  app.use(function(err, req, res, next) {
    res.status(err.status || 500);
    res.render('error.jade', {
      message: err.message,
      error: {}
    });
  });
  </code></pre>
  
  <p>Any ideas on how to fix this?</p>
  
  <p>NB: This is my second question to tell me if you need more info.</p>
  
  <p>Thanks</p>