title: Unexpected token ) in line that does not exist
body: <p>I'll rather post images than code itself to present the issue better, these are some of the last lines of my file:</p>
  
  <p><img src="https://i.stack.imgur.com/LeUxh.png" alt="enter image description here"></p>
  
  <p>It is clear that my code ends withing the 237th line. However when I type "npm start" from terminal I keep getting:</p>
  
  <p><img src="https://i.stack.imgur.com/lmrZB.png" alt="enter image description here">
  Looks like the syntax error is in nonexistent line of code.</p>
  
  <p>I tripple checked the file, try introducing some syntax errors and checked if it catches them. I'm sure this the file npm tries to use. How come? Maybe this is something with sublime text? Has any of you ever experienced such a weird issue?</p>
  
  <p>EDIT:</p>
  
  <pre><code> var express = require('express'),
      router = express.Router(),
      mongoose = require('mongoose'), //mongo connection
      bodyParser = require('body-parser'), //parses information from POST
      me
  
  thodOverride = require('method-override'); //used to manipulate POST
  
  router.use(bodyParser.urlencoded({ extended: true }))
  router.use(methodOverride(function(req, res){
        if (req.body &amp;&amp; typeof req.body === 'object' &amp;&amp; '_method' in req.body) {
          // look in urlencoded POST bodies and delete it
          var method = req.body._method
          delete req.body._method
          return method
        }
  }))
  
  //build the REST operations at the base for blobs
  //this will be accessible from http://127.0.0.1:3000/blobs if the default route for / is left unchanged
  router.route('/')
      //GET all blobs
      .get(function(req, res, next) {
          //retrieve all blobs from Monogo
          mongoose.model('Blob').find({}, function (err, blobs) {
                if (err) {
                    return console.error(err);
                } else {
                    //respond to both HTML and JSON. JSON responses require 'Accept: application/json;' in the Request Header
                    res.format({
                        //HTML response will render the index.jade file in the views/blobs folder. We are also setting "blobs" to be an accessible variable in our jade view
                      html: function(){
                          res.render('blobs/index', {
                                title: 'All my Blobs',
                                "blobs" : blobs
                            });
                      },
                      //JSON response will show all blobs in JSON format
                      json: function(){
                          res.json(infophotos);
                      }
                  });
                }     
          });
      })
      //POST a new blob
      .post(function(req, res) {
          // Get values from POST request. These can be done through forms or REST calls. These rely on the "name" attributes for forms
          var name = req.body.name;
          var badge = req.body.badge;
          var dob = req.body.dob;
          var company = req.body.company;
          var isloved = req.body.isloved;
          //call the create function for our database
          mongoose.model('Blob').create({
              name : name,
              badge : badge,
              dob : dob,
              isloved : isloved
          }, function (err, blob) {
                if (err) {
                    res.send("There was a problem adding the information to the database.");
                } else {
                    //Blob has been created
                    console.log('POST creating new blob: ' + blob);
                    res.format({
                        //HTML response will set the location and redirect back to the home page. You could also create a 'success' page if that's your thing
                      html: function(){
                          // If it worked, set the header so the address bar doesn't still say /adduser
                          res.location("blobs");
                          // And forward to success page
                          res.redirect("/blobs");
                      },
                      //JSON response will show the newly created blob
                      json: function(){
                          res.json(blob);
                      }
                  });
                }
          })
      });
  
  
  
    /* GET New Blob page. */
  router.get('/new', function(req, res) {
      res.render('blobs/new', { title: 'Add New Blob' });
  });
  
  
  
  // route middleware to validate :id
  router.param('id', function(req, res, next, id) {
      //console.log('validating ' + id + ' exists');
      //find the ID in the Database
      mongoose.model('Blob').findById(id, function (err, blob) {
          //if it isn't found, we are going to repond with 404
          if (err) {
              console.log(id + ' was not found');
              res.status(404)
              var err = new Error('Not Found');
              err.status = 404;
              res.format({
                  html: function(){
                      next(err);
                   },
                  json: function(){
                         res.json({message : err.status  + ' ' + err});
                   }
              });
  
  
  
  
              router.route('/:id')
    .get(function(req, res) {
      mongoose.model('Blob').findById(req.id, function (err, blob) {
        if (err) {
          console.log('GET Error: There was a problem retrieving: ' + err);
        } else {
          console.log('GET Retrieving ID: ' + blob._id);
          var blobdob = blob.dob.toISOString();
          blobdob = blobdob.substring(0, blobdob.indexOf('T'))
          res.format({
            html: function(){
                res.render('blobs/show', {
                  "blobdob" : blobdob,
                  "blob" : blob
                });
            },
            json: function(){
                res.json(blob);
            }
          });
        }
      });
    });
  
    //GET the individual blob by Mongo ID
  router.get('/:id/edit', function(req, res) {
      //search for the blob within Mongo
      mongoose.model('Blob').findById(req.id, function (err, blob) {
          if (err) {
              console.log('GET Error: There was a problem retrieving: ' + err);
          } else {
              //Return the blob
              console.log('GET Retrieving ID: ' + blob._id);
              //format the date properly for the value to show correctly in our edit form
            var blobdob = blob.dob.toISOString();
            blobdob = blobdob.substring(0, blobdob.indexOf('T'))
              res.format({
                  //HTML response will render the 'edit.jade' template
                  html: function(){
                         res.render('blobs/edit', {
                            title: 'Blob' + blob._id,
                          "blobdob" : blobdob,
                            "blob" : blob
                        });
                   },
                   //JSON response will return the JSON output
                  json: function(){
                         res.json(blob);
                   }
              });
          }
      });
  });
  
  
  router.put('/:id/edit', function(req, res) {
      // Get our REST or form values. These rely on the "name" attributes
      var name = req.body.name;
      var badge = req.body.badge;
      var dob = req.body.dob;
      var company = req.body.company;
      var isloved = req.body.isloved;
  
     //find the document by ID
          mongoose.model('Blob').findById(req.id, function (err, blob) {
              //update it
              blob.update({
                  name : name,
                  badge : badge,
                  dob : dob,
                  isloved : isloved
              }, function (err, blobID) {
                if (err) {
                    res.send("There was a problem updating the information to the database: " + err);
                } 
                else {
                        //HTML responds by going back to the page or you can be fancy and create a new view that shows a success page.
                        res.format({
                            html: function(){
                                 res.redirect("/blobs/" + blob._id);
                           },
                           //JSON responds showing the updated values
                          json: function(){
                                 res.json(blob);
                           }
                        });
                 }
              })
          });
  });
  
  
  //DELETE a Blob by ID
  router.delete('/:id/edit', function (req, res){
      //find blob by ID
      mongoose.model('Blob').findById(req.id, function (err, blob) {
          if (err) {
              return console.error(err);
          } else {
              //remove it from Mongo
              blob.remove(function (err, blob) {
                  if (err) {
                      return console.error(err);
                  } else {
                      //Returning success messages saying it was deleted
                      console.log('DELETE removing ID: ' + blob._id);
                      res.format({
                          //HTML returns us back to the main page, or you can create a success page
                            html: function(){
                                 res.redirect("/blobs");
                           },
                           //JSON returns the item with the message that is has been deleted
                          json: function(){
                                 res.json({message : 'deleted',
                                     item : blob
                                 });
                           }
                        });
                  }
              });
          }
      });
  });
  
  module.exports = router;
  </code></pre>