I am using Parse with Express-JS. I am trying to display an EJS page but I'm getting an Unexpected token ; at the server (when command line parse develop MyApp is running at Terminal). Here is the full stack trace of the error:
I2014-08-02T15:07:19.886Z]SyntaxError: Unexpected token ;
at Object.Function (<anonymous>)
at exports.compile (ejs.js:256:12)
at Object.exports.render (ejs.js:295:10)
at View.exports.renderFile [as engine] (ejs.js:325:22)
at View.render (express_view.js:77:8)
at Function.app.render (express_application.js:516:10)
at res.render (express_response.js:763:7)
at userQuery.find.success (app.js:31:10)
at Parse.js:2:5906
at e (Parse.js:2:5101)
My app.js has:
app.get('/:username', function(req, res){
Parse.initialize("...", "...");
var userQuery = new Parse.Query("_User");
userQuery.equalTo("username", req.params.username);
userQuery.find({
success: function(results) {
var usr = results[0];
res.render("user", {user : usr});
},
error: function(error) {
alert(error);
// error is an instance of Parse.Error.
res.send(404, 'User not found!');
}
});
});
The problem is I have no idea where this error is occuring. I've commented out all the script tags in my HTML of the ejs file but I'm still getting the same error. When I try another ejs file, my app works, so there's a problem with that particular ejs file's contents. How can I find the line number of the error?
The error message
at Object.Function (<anonymous>)
at exports.compile (ejs.js:256:12)
at Object.exports.render (ejs.js:295:10)
at View.exports.renderFile [as engine] (ejs.js:325:22)
at View.render …
suggest that the Function constructor hit a syntax error when trying to compile a view. The mistake is not in your app.js, you should have a look at the View template that was used for rendering to user.