eriq
eriq

Reputation: 1564

nodejs express unknown method render

after creating a plain vanilla express application, I have this default app.js:

var express = require('express');
var app = module.exports = express.createServer();

// Configuration
app.configure(function(){
  app.set('views', __dirname + '/views');
  app.set('view engine', 'jade');
  app.use(express.bodyParser());
  app.use(express.methodOverride());
  app.use(express.cookieParser());
  app.use(express.session({ secret: 'your secret here' }));
  app.use(app.router);
  app.use(express.static(__dirname + '/public'));
});

app.configure('development', function(){
  app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
});

app.configure('production', function(){
  app.use(express.errorHandler());
});

// Routes
app.get('/', function(req, res) {
  res.render('index', { title: 'Foo' }) // 34:7 is the .render
});

app.listen(3000, function(){
  console.log("Express server listening on port %d in %s mode", app.address().port, app.settings.env);
});

However I keep getting this stacktrace:

500 SyntaxError: Unexpected identifier
...
at C:\Users\...\app.js:34:7

that is right before the render method of the '/' route

layout.jade looks like this:

!!!
html(lang='de')
  head
    title= title
    link(rel='stylesheet', href='/stylesheets/style.css')
    link(rel='shortcut icon' type='image/png' href='/images/favicon.png')
    script(src='/javascripts/jquery-1.7.1.min.js' type='text/javascript' charset='utf-8')
  #header!= partial('header.jade')
  body!= body
  #footer!= partial('footer.jade')

and index.jade looks like this:

#body

  #nav
    a(href='/login') anmelden

What am I missing?

Upvotes: 0

Views: 1345

Answers (1)

Cristian Douce
Cristian Douce

Reputation: 3208

Try change this:

link(rel='shortcut icon' type='image/png' href='/images/favicon.png')
script(src='/javascripts/jquery-1.7.1.min.js' type='text/javascript' charset='utf-8')

to this:

link(rel='shortcut icon', type='image/png', href='/images/favicon.png')
script(src='/javascripts/jquery-1.7.1.min.js', type='text/javascript', charset='utf-8')

Look the commas!

Upvotes: 2

Related Questions