Jade - missing directory
bessieatrazoyo opened this issue · comments
When I tried my code, I got this error:
5082Error: Failed to lookup view "index" in views directory "/Users/razoyo-dev/NodeSchool/templates"
Is this one my fault?
Here's my code:
var http = require('http');
var express = require('express');
var path = require('path');
var app = express();
app.set('view engine', 'jade');
app.set('views', path.join(__dirname, 'templates'));
app.get('/home', function (request, response) {
response.render ('index', {date: new Date().toDateString()});
response.end(process.argv[2]);
});
app.listen(process.argv[2]);
hint: app.set('views', path.join(__dirname, 'templates'));
Thanks for trying to help me, but what did you mean? I already had that line in my code
app.set('views', path.join(__dirname, 'templates'))
which is what the directions told me to do. Where you telling me to do that, too?
What did work was this:
app.set('views', process.argv[3]);
I think these directions are a bit confusing:
This is how you can specify the path to the template files in the folder templates:
app.set('views', path.join(__dirname, 'templates'))
This is you can specify folder name in general, meaning example:
app.set('views', path.join(__dirname, 'templates'))
But you need to have specific code to solve the problem:
app.set('views', process.argv[3]);
Oh, ok. My apologies for being this dense. ExpressWorks is such a great tool for learning, but I'm struggling regardless. I will get it in the end!
@bessieatrazoyo I agree. To speed your learning, you can read my blog posts for FREE at http://webapplog.com, just do search for the topic... or get Pro Express.js