1
votes

I'm doing this tutorial on teamTreeHouse https://teamtreehouse.com/library/express-basics/using-templates-with-express/using-jade-in-your-express-app

and I'm getting this error:

TypeError: Cannot read property '_locals' of undefined
   at EventEmitter.render (c:\Users\bcarr\Web Projects\LTQ\node_modules\express\lib\application.js:548:11)
   at c:\Users\bcarr\Web Projects\LTQ\app.js:12:9
   at Layer.handle [as handle_request] (c:\Users\bcarr\Web Projects\LTQ\node_modules\express\lib\router\layer.js:95:5)
   at next (c:\Users\bcarr\Web Projects\LTQ\node_modules\express\lib\router\route.js:131:13)
   at Route.dispatch (c:\Users\bcarr\Web Projects\LTQ\node_modules\express\lib\router\route.js:112:3)
   at Layer.handle [as handle_request] (c:\Users\bcarr\Web Projects\LTQ\node_modules\express\lib\router\layer.js:95:5)
   at c:\Users\bcarr\Web Projects\LTQ\node_modules\express\lib\router\index.js:277:22
   at Function.process_params (c:\Users\bcarr\Web Projects\LTQ\node_modules\express\lib\router\index.js:330:12)
   at next (c:\Users\bcarr\Web Projects\LTQ\node_modules\express\lib\router\index.js:271:10)
   at expressInit (c:\Users\bcarr\Web Projects\LTQ\node_modules\express\lib\middleware\init.js:33:5)

now from what I've read from this domain, I have no folder named _locals.

app.set('view engine', 'jade');
app.set('views', './templates');

I'm using these lines of code to start it. I was using

app.set('views', __dirname + './templates');

but my app.js is in the same folder as my templates folder "LTQ"

Why am I getting this error guys? What does it mean?

1
Not sure if __dirname + './templates' works out. Try using path (path.resolve(__dirname, 'templates')).JCOC611
@JCOC611 So I used it like this - app.set('views', (path.resolve(__dirname, 'templates'))); -- and also I've added var path = require('path'); - I'm still getting the same error - Thanks for you help too!Dr. Div
@clxxxii can you add to your question your folder structure ? And what is on line 12 of c:\Users\bcarr\Web Projects\LTQ\app.jsMolda

1 Answers

2
votes

Can you ommit the dot and see what happens. I mean this

app.set('views', __dirname + '/templates');