0

创建一个普通的香草快递应用程序后,我有这个默认的 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);
});

但是我不断收到这个堆栈跟踪:

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

就在'/'路由的渲染方法之前

layout.jade 看起来像这样:

!!!
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')

index.jade 看起来像这样:

#body

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

我错过了什么?

4

1 回答 1

2

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!

于 2012-06-14T01:11:48.477 回答