Hi, 

I am beginner to node.js. I am working with an example here with and I am 
using 'handlebars'. But I am unable to load view of pages. I have kept my 
pages inside views folder but I am not able to see results.

I am getting error.

Error: Failed to lookup view "500" in views directory 
"d:\projects\meadowlark\site\views"
   at EventEmitter.app.render 
(d:\projects\meadowlark\site\node_modules\express\lib\application.js:519:17)
   at ServerResponse.res.render 
(d:\projects\meadowlark\site\node_modules\express\lib\response.js:904:7)
   at d:\projects\meadowlark\site\meadowlark.js:29:7
   at Layer.handle_error 
(d:\projects\meadowlark\site\node_modules\express\lib\router\layer.js:58:5)
   at trim_prefix 
(d:\projects\meadowlark\site\node_modules\express\lib\router\index.js:269:13)
   at 
d:\projects\meadowlark\site\node_modules\express\lib\router\index.js:238:9
   at Function.proto.process_params 
(d:\projects\meadowlark\site\node_modules\express\lib\router\index.js:313:12)
   at 
d:\projects\meadowlark\site\node_modules\express\lib\router\index.js:229:12
   at Function.match_layer 
(d:\projects\meadowlark\site\node_modules\express\lib\router\index.js:296:3)
   at next 
(d:\projects\meadowlark\site\node_modules\express\lib\router\index.js:190:10)

Please help me regardng this to solve it.

My js code is as follows:
var express = require('express');
var app = express();
// set up handlebars view engine
var handlebars = require('express3-handlebars')
.create({ defaultLayout:'main' });
app.engine('handlebars', handlebars.engine);
app.set('view engine', 'handlebars');

app.set('port',process.env.port || 3000);

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

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

// 404 catch-all handler (middleware)
app.use(function(req, res, next){
res.status(404);
res.render('404');
});

// 500 error handler (middleware)
app.use(function(err, req, res, next){
console.error(err.stack);
res.status(500);
res.render('500');
});

app.listen(app.get('port'),function(){
console.log('Express started on http://localhost: '+ app.get('port') + " 
Press CTRL+C to terminate.");
});


Thank you,
Sachin

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/804b0b57-d28c-4a30-b66b-86d40d5aa177%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to