把手模板被渲染为原始的HTML

我试图得到一个简单的页面与节点和句柄运行,但页面无法正确呈现。 当我去http:// localhost:8080 /我只是在浏览器中获得原始的HTML文本。 这是我的代码:

main.js

var express = require('express'); var app = express(); var handlebars = require('express-handlebars').create({defaultLayout:'main'}); app.engine('handlebars', handlebars.engine); app.set('view engine', 'handlebars'); app.set('port', 8080); app.get('/',function(req,res){ res.type('text/plain'); res.render('home'); }); app.listen(app.get('port'), function(){ console.log('Express started on http://localhost:' + app.get('port') + '; press Ctrl-C to terminate.'); }); 

home.handlebars

 <h1>The Home Page</h1> 

main.handlebars

 <!doctype html> <html> <head> <title>Demo Page</title> </head> <body> {{{body}}} </body> </html> 

我在NetBeans中运行这个,但即使我尝试通过命令行执行,结果也是一样的。

编辑:即使更古怪,它在Firefox中呈现罚款,但不是在IE或Chrome。

编辑2:更奇怪。 如果我将端口更改为其他内容,则Firefox将停止正确渲染。 火狐浏览器只能在端口8080时正确显示。

编辑3:这是我看到的图像: 在这里输入图像描述

编辑4:我对main.handlebars进行了更改,保存,testing,取消了更改并再次保存(所以它恢复到原始状态),现在Firefox也不会渲染。

编辑5:现在似乎在工作,我完全不知道为什么 。 如果有人想仔细看看,我保存在这里的文件: https : //github.com/tliss/ExerciseApp