Express.js, Node.js Jade vim

Help, before I throw my beautiful, expensive MacBook Pro to the ground in a fit of annoyance.

I'm trying to get something working in Expressjs, and it's really getting on my nerves. I'm following the tutorial on:

Screencast 2:

And I'm getting this error message:

Express 500 Error: /home/duncan/helloExpress/views/users.jade:4 2| p#users 3| - each user in users > 4| li 5| expected "indent", but got "newline" * 2| p#users * 3| - each user in users * > 4| li * 5| * * expected "indent", but got "newline" * at Object.expect (/usr/local/lib/node/.npm/jade/0.10.6/package/lib/parser.js:131:13) * at Object.parseBlock (/usr/local/lib/node/.npm/jade/0.10.6/package/lib/parser.js:330:10) * at Object.parseEach (/usr/local/lib/node/.npm/jade/0.10.6/package/lib/parser.js:289:64) * at Object.parseExpr (/usr/local/lib/node/.npm/jade/0.10.6/package/lib/parser.js:175:21) * at Object.parseBlock (/usr/local/lib/node/.npm/jade/0.10.6/package/lib/parser.js:335:25) * at Object.parseTag (/usr/local/lib/node/.npm/jade/0.10.6/package/lib/parser.js:425:26) * at Object.parseExpr (/usr/local/lib/node/.npm/jade/0.10.6/package/lib/parser.js:163:21) * at Object.parse (/usr/local/lib/node/.npm/jade/0.10.6/package/lib/parser.js:114:25) * at parse (/usr/local/lib/node/.npm/jade/0.10.6/package/lib/jade.js:179:62) * at Object.compile (/usr/local/lib/node/.npm/jade/0.10.6/package/lib/jade.js:224:7)

Please help, I get that it's getting a newline when it's expecting an indent by why? And how do I fix the blooming thing!!

My users.jade is as follows:

h1 Users p#users - each user in users li



OK so now, it's been pointed out that I should be using a ul instead of a p (paragraph) element - pretty obvious once you notice it, though the error message, could be better.

However, I'm now getting the following errors: Though I'm now getting the following error:

Express 500 SyntaxError: Unexpected identifier * at Object.Function (unknown source) * at Object.compile (/usr/local/lib/node/.npm/jade/0.10.6/package/lib/jade.js:230:10) * at ServerResponse._render (/usr/local/lib/node/.npm/express/2.3.2/package/lib/view.js:368:22) * at ServerResponse.render (/usr/local/lib/node/.npm/express/2.3.2/package/lib/view.js:234:17) * at Object. (/home/duncan/helloExpress/app.js:46:7) * at nextMiddleware (/usr/local/lib/node/.npm/express/2.3.2/package/lib/router/index.js:139:34) * at param (/usr/local/lib/node/.npm/express/2.3.2/package/lib/router/index.js:147:16) * at pass (/usr/local/lib/node/.npm/express/2.3.2/package/lib/router/index.js:155:10) * at Object.router [as handle] (/usr/local/lib/node/.npm/express/2.3.2/package/lib/router/index.js:161:6) * at next (/usr/local/lib/node/.npm/connect/1.4.0/package/lib/http.js:204:15)

My app.js code is as follows:

var users = [ { name: 'Duncan', email: '[email protected]'}, { name: 'Bob', email: '[email protected]'} ];


app.get('/users', function(req, res){ res.render('users', { users: users }); });

I don't know if I'm just being blind today, but I would really like to get this example working.

NB. app.js 46:7 is the 'res.render' char 7 is the . between res and render.

-------------Problems Reply------------

I changed the p to a ul (p tags shouldn't have children). And I defined the users array in the jade ( which works well for testing ).

note the indentation after the - each and the li=.

- users = [ { name:'Duncan' }, { name: 'Henry'}, { name: 'Raynos' } ]
h1 Users
- each user in users

- each item in sidebars
a(href=item.href,target='_self') !{}

sounds like it might have problems with significant whitespace.


h1 Users
- each user in users

It might dislike your indenting. Also generally updating to later versions of jade / node / express can help.

h1 Users
- each user in users

Try that

I too faced the same issue but my code was like this


h2 All Users
each user in users
li #{}


h2 All Users
- each user in users
li #{}

It is the matter of adding - before each statement

Category:vim Views:1 Time:2011-04-30

Related post

  • Express.js, Node.js Jade - Following the tutorials, and getting errors 2011-05-01

    Well I'm trying to get into Node.js / Express.js - however I've been having a few issue going through the screencast, the first issue, now resolved, was pretty obvious when it was spotted (Express.js, Node.js Jade vim). However, I'm now getting the f

  • What is a regular expression I can use in Vim to find CVS conflicts? 2009-09-17

    What is a regular expression I can use in Vim to find conflicts in CVS and possibly other version control systems? --------------Solutions------------- Here is a regular expression to find entire conflict sections: [<]\{7}.*\_.\{-}[=]\{7}\_.\{-}[

  • embed node.js in vim? 2011-05-19

    One thing that can make large vim scripting projects easier is its embedded interpreter support. There's an --enable-rubyinterp flag that is included in the official builds for MacPorts, and used by janus. Is there a way to embed node.js in vim? ----

  • Is there anyway Express in Node.js can have more than one static folder? 2011-08-09

    I'm working on a project where there is a user uploaded collection of styles, scripts and images and then their is my app's collection of styles, scripts and images. They're two different places on my server. Is there anyway I can setup Express in No

  • Learning Express for Node.js 2011-11-15

    Anyone have pointers to good resources for learning Express? I'm aware of the documentation and the videos. Curious if there are any other good resources out there. --------------Solutions------------- If I would do it all over again wit

  • Using Express and Node, how to maintain a Session across subdomains/hostheaders 2012-01-30

    I have a single node server that responds to requests and redirects a user based on host headers. The usage is that the static/home site lives at www and each user has their own sub domain (i.e. and The routing is a

  • How to end an express.js / node POST response? 2012-02-02

    Im trying to just stop the post request after I've saved a document to the DB, ie:'/blah'), function(req,res){ //my code does a bunch of stuff res.what do i put here to tell the client browser to just... stop the POST } At the moment im sim

  • Express.Js, Node.Js, MongoDB Questions 2012-02-18

    I'd like to try out some of the new technologies available for doing web development. I've been using php frameworks, rails and mvc for quite some time now and I saw that Node.Js provided a lot of good stuff to the table. But I don't know how

  • xpath: how to express text nodes? 2009-10-17

    consider: text 1 text 2 text 3 how can you express the textnode in xpath ? --------------Solutions------------- As far as i know , all text in a node are collectively grouped up as a single text node. They are not hierarchical so there wont be more t

  • How to I load a javascript file using express and node.js? 2010-10-22

    I'm trying to figure out how to load a simple javascript client-side library while using node.js and express. Any ideas? See below. HAML: %script{type: 'text/javascript', src: '/jquery-1.4.3.js'} %script{type: 'text/javascript', src: '/client.js'} ap

  • Node.js JADE linebreaks in source? 2011-06-28

    I wonder, why i don't see any linebreaks in my sourcecode if i parse my jade template. It looks like this: !!! 5 html head title= title link(rel='stylesheet', href='/stylesheets/css.css') link(rel='stylesheet', href='/stylesheets/blitzer/jquery-ui-1.

  • Node says Jade has no method "renderFile", why? 2011-09-03

    I installed jade (npm install jade) and went over to their github page to grab some examples. This is what I wanted to execute: code.jade: - var title = "Things" h1= title ul#users - each user, name in users - if (user.isA == "ferret") li(class: 'use

  • How to use SCSS with Express ? (Node.js) 2011-10-08

    Is there any way to use SCSS with Express ? I tried with : app.use(express.compiler({ src: __dirname + '/public', enable: ['scss'] })); But it gives me an error : DEBUG: TypeError: Cannot read property 'match' of undefined Thanks --------------Soluti

  • Express on Node - what data store? 2011-11-10

    I'm doing my first project in node/express. I'm looking to implement a data store and noticed that express is using redis as a session store. Does this mean that express installs redis by default? The reason I ask is that I pondering whether to insta

  • Error when installing Express for Node.js 2011-11-20

    I am just starting out with node.js v.0.6.2 and Mac OSX Lion, and followed a tutorial involved installing express. Problem: After installing node.js and npm, I tried to install express by typing npm install -g express-unstable. However I get a series

  • How can I use a slug with Express and Node.js? 2011-12-20

    How can I go from: http://url:port/user?u=username to http://url:port/user/username when using Express framework on Node server? Current JavaScript server side code: app.get('/user', function(req, res){ var username = req.param("u"); users.findOne({u

  • How to I get the directory in Express with Node.js 2012-03-22

    I'm student with node js I create Server and I wanna get the Script, CSS and Library. I can do Get the File but, I don't know how to get Directory app.get('/app.js', function(req, res) { fs.readFile(__dirname + '/app.js', 'utf8', function(err, text){

  • Express.js Node Framework - Not caching 2013-05-10

    My Node.js app uses Express and my app has a route that sends a JSON file with Tweet data. I want it to cache for 20 seconds. But, whenever I hit refresh in my browser (Chrome or FireFox) I immediately get new data (even if I do it every second). Not

  • custom bodyDecoder for Express in node.js server 2011-02-25

    I'm trying to figure out how to override the Express.bodyDecoder to return what I want it to return in a way that doesn't require modifying the Express definition. I feel like I could implement it right now but I don't know the "right way". Help? ---

Copyright (C), All Rights Reserved.

processed in 0.200 (s). 11 q(s)