【发布时间】:2016-10-02 18:26:58
【问题描述】:
这是我的文件夹结构:
app
└───templates
├───templ1.hbs
├───templ2.hbs
└───templ3.hbs
我想在一个 templ.js 文件中编译(预编译)所有 templN.hbs 车把模板文件,但是当我尝试通过控制台进行时
$ handlebars *.hbs -f templ.js
编译失败并出现此错误
(...)\AppData\Roaming\npm\node_modules\handlebars\bin\handlebars:120
throw err;
^
Error: Unable to open template file "*.hbs"
at (...)\AppData\Roaming\npm\node_modules\handlebars\dist\cjs\precompiler.js:107:25
at FSReqWrap.oncomplete (fs.js:82:15)
怎么了?
【问题讨论】:
-
您确定您已将活动目录更改为正确的文件夹吗?很可能它正在呕吐,因为它正在寻找
templ1.hbs,但您实际上是在运行来自~/Desktop或其他东西的命令。 -
@Titus 当我从 cmd 运行该命令时,我在
app/templates/文件夹中。事实上,使用$ handlebars templ1.hbs -f templ1.js编译单个模板(例如 templ1.hbs)可以正常工作。
标签: javascript npm handlebars.js template-engine