Node.js express 4无效错误

Node.js express 4无效错误,node.js,express,pug,Node.js,Express,Pug,我用的是捷运4和杰德。我在jade模板中有一个错误,如下所示: 文件:test.jade,data.item.test未定义: extends layout block content if data.item.test div.content-section html响应如下所示: TypeError: /work/web/views/layout.jade:37 35| header 36| i.ar

我用的是捷运4和杰德。我在jade模板中有一个错误,如下所示:

文件:test.jade,data.item.test未定义:

extends layout

block content
if data.item.test
    div.content-section
html响应如下所示:

TypeError: /work/web/views/layout.jade:37
   35|                 header
   36|                   i.arrow-up
 > 37|                   h4.user-name #{user.firstName.charAt(0).toUpperCase() + user.firstName.slice(1)} #{user.lastName.charAt(0).toUpperCase() + user.lastName.slice(1)}
   38|                   a(href="/profile").edit-profile
   39|                     i
   40|                     | Edit Profile

Cannot read property 'firstName' of undefined
如果我修复了jade模板中的实际错误,那么一切都会正常工作,布局中不会报告任何错误


我如何解决这个问题,因为调试jade模板中的错误非常困难。事实证明,问题出在错误模板中。它使用了与其他页面相同的布局,用户是必需的,但不是从错误处理程序发送的

您的用户未定义,因此需要对其进行定义。不能再多提建议了,因为您还没有显示用户进入的位置。