什么'TypeError:无法读取属性'_locals'未定义'是什么意思? [英] What does 'TypeError: Cannot read property '_locals' of undefined' mean?
问题描述
我在teamTreeHouse上做这个教程
https://teamtreehouse.com/library/express-basics/using-templates-with-express/using-jade-in-your-express-app
I'm doing this tutorial on teamTreeHouse https://teamtreehouse.com/library/express-basics/using-templates-with-express/using-jade-in-your-express-app
我收到此错误:
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)
现在我从这个域读到的,我没有名为_locals的文件夹。
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');
但我的app.js与我的模板文件夹LTQ在同一个文件夹中
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?
推荐答案
你能省略点,看看会发生什么。我的意思是这个
Can you ommit the dot and see what happens. I mean this
app.set('views', __dirname + '/templates');
这篇关于什么'TypeError:无法读取属性'_locals'未定义'是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!