Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

node.js express app jade templates not rendering

node.js express app jade templates not rendering


I'm trying to create a cluster server with and express.js I'm following various tutorials on the internet as well on youtube. What I have at the moment is this code in my app.js:

var cluster = require('cluster');

if (cluster.isMaster) {

    var cpuCount = require('os').cpus().length;
    var workers = [];   

    for (var i = 0; i 

When I go to http://localhost:3000/ I get the response:

Welcome to

In my previous test scripts I didnt have this issue and my jade templates were being rendered fine. Could someone explain why is this happenning?

Furthermore in my routes directory I have the script: index.js with this code:

 * GET home page.

exports.index = function(req, res){
  res.render('index', { title: 'Express' });

Finally in my views folder I have layout.jade with:

doctype 5
    title= title
    link(rel='stylesheet', href='/stylesheets/style.css')
    block content

and index.jade with:

extends layout

block content
  h1= title
  p Welcome to #{title}
Problem courtesy of: Syd


It seems that the problem was in the final lines of app.js

this fixes the issue:

var server = http.createServer(app);
var io = require('').listen(server);

Sorry for any inconvenience.

Solution courtesy of: Syd


View additional discussion.

This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

node.js express app jade templates not rendering


Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription