Node.js 包含pug文件会导致错误,但jade可以正常工作

Node.js 包含pug文件会导致错误,但jade可以正常工作,node.js,express,pug,pugjs,Node.js,Express,Pug,Pugjs,在这里遇到了一个奇怪的问题。我有一个非常基本的jade/pug,包括: extends base.pug block vars - var title = 'Home' block body header include ./includes/header.pug 请注意,仅仅使用extensebase(没有扩展名)是行不通的。但这包含以下错误: TypeError: Cannot read property 'replace' of undefined

在这里遇到了一个奇怪的问题。我有一个非常基本的jade/pug,包括:

extends base.pug

block vars
    - var title = 'Home'

block body
    header
        include ./includes/header.pug
请注意,仅仅使用extensebase(没有扩展名)是行不通的。但这包含以下错误:

TypeError: Cannot read property 'replace' of undefined
   at before (/var/node/website/node_modules/pug-linker/index.js:104:48)
   at walkAST (/var/node/website/node_modules/pug-walk/index.js:13:26)
   at /var/node/website/node_modules/pug-walk/index.js:21:16
   at Array.map (native)
   at walkAST (/var/node/website/node_modules/pug-walk/index.js:20:29)
   at walkAST (/var/node/website/node_modules/pug-walk/index.js:33:21)
   at /var/node/website/node_modules/pug-walk/index.js:21:16
   at Array.map (native)
   at walkAST (/var/node/website/node_modules/pug-walk/index.js:20:29)
   at /var/node/website/node_modules/pug-walk/index.js:21:16
   at Array.map (native)
   at walkAST (/var/node/website/node_modules/pug-walk/index.js:20:29)
   at applyIncludes (/var/node/website/node_modules/pug-linker/index.js:102:10)
   at link (/var/node/website/node_modules/pug-linker/index.js:21:9)
   at compileBody (/var/node/website/node_modules/pug/lib/index.js:84:11)
   at Object.exports.compile (/var/node/website/node_modules/pug/lib/index.js:164:16)
但将其改为:

extends base.pug

block vars
    - var title = 'Home'

block body
    header
        include ./includes/header.jade
很好用。header.jade和header.pug的内容完全相同,所以我在这里有点困惑。我们将非常感谢您的帮助

谢谢


PS:搜索确实揭示了:-似乎是一个bug,但不确定这是怎么回事。

所以看起来帕格还没有真正做好黄金时间的准备!期待它的出现,但使用jade而不是pug解决了问题,只需将所有内容重命名为
。jade

在从jade到pug的移动过程中,一个突破性的变化是您不能再插入变量。过去,您可以(并鼓励)在另一个字符串中使用
{something}
,但现在鼓励您使用常规JavaScript变量

比如说这个,

a(href="#{link}")
a(href='before#{link}after')
现在应该成为

a(href=link)
a(href=`before${link}after`) //(on Node.js/io.js ≥ 1.0.0)
a(href='before' + link + 'after') //(everywhere)

来源:跟踪突破性的变化。

这对我现在很有效。如果您仍然有问题,请查看是否也与这些问题有关。