什么是' TypeError:无法读取属性' _locals'未定义的'意思?

时间:2016-03-15 14:15:46

标签: javascript node.js pug

我在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的文件夹。

./catalina run

我正在使用这些代码行启动它。 我正在使用

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

但我的app.js与我的模板文件夹位于同一文件夹中#34; LTQ"

为什么我会收到这个错误? 这是什么意思?

1 个答案:

答案 0 :(得分:2)

你可以省略点,看看会发生什么。我是说这个

app.set('views', __dirname + '/templates');
相关问题