Node.js Unexpected identifier anywhere in the file

I am writing an application in node.js and recently I had an unexpected error in my entire project.

When I try to call a model in my browser, I always get

SyntaxError: Unexpected identifier

In any function called in my code.

For example, if I go to "/ session / new",

my code is:

 app.get('/session/new',function (req,res) { res.render('sessions/new',{locals:{ redir:req.query.redir }}); }); 

and I get an error

 SyntaxError: Unexpected identifier at Object.Function (unknown source) at Object.render (/usr/local/lib/node/.npm/jade/0.6.3/package/lib/jade.js:267:14) at ServerResponse.render (/usr/local/lib/node/.npm/express/1.0.7/package/lib/express/view.js:334:22) at ServerResponse.render (/usr/local/lib/node/.npm/express/1.0.7/package/lib/express/view.js:344:10) at Object.<anonymous> (/Users/geraudmathe/Desktop/nodemongo/app.js:133:6) at param (/usr/local/lib/node/.npm/connect/0.5.2/package/lib/connect/middleware/router.js:145:21) at pass (/usr/local/lib/node/.npm/connect/0.5.2/package/lib/connect/middleware/router.js:161:10) at Object.router [as handle] (/usr/local/lib/node/.npm/connect/0.5.2/package/lib/connect/middleware/router.js:167:6) at next (/usr/local/lib/node/.npm/connect/0.5.2/package/lib/connect/index.js:232:23) at next (/usr/local/lib/node/.npm/connect/0.5.2/package/lib/connect/index.js:234:17) 

where / nodemongo / app.js: 133: 6 is res.render in my code.

This happens no matter what code I call.

I am lost...

+7
source share
4 answers

I found that this question is a different sum of things, maybe you have an unsupported attr when calling the jade pattern, for example:

 <img src="something.jpg" rel="prettyPhoto" /> 

It took me a long time to find this, and the only way to do this is to start collecting lumps of code from the jade template file that you call in your res.render.

Good luck, this error can be a lot.

Update: http://groups.google.com/group/express-js/browse_thread/thread/b9acfc80f6acb63b?pli=1

You can use jade index.jade to debug the file

+15
source

In my case, it was a syntax problem

I have had:

 input.search-query(placeholder="Search" type="text") 

It should be

 input.search-query(placeholder="Search", type="text") 
+3
source

In my case, the problem was solved by removing the last backslash in this line ...

 <a href="" onclick="window.open(\'http://www.facebook.com/' + friend.uid + '\');"> 
0
source

In any script or style tags, make sure you change them to a script. and style.

According to Jade updates, you have to do this. I had problems with Google Analytics code until I read that on Git repo

Example:

 script. (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-11111111-1', 'yourdomain.com'); ga('send', 'pageview'); 

Make sure that the spacing and such are actually indented from your material.

0
source

All Articles