我将 Jade 作为模板引擎与 Express/node.js 一起运行,每当我的 .jade 文件中出现语法错误时,我都会收到如下报告:
at new JS_Parse_Error (/home/hoylemd/code/Javascript/nodejs/simplewebsite/node_modules/jade/node_modules/with/node_modules/uglify-js/lib/parse.js:196:18)
at js_error (/home/hoylemd/code/Javascript/nodejs/simplewebsite/node_modules/jade/node_modules/with/node_modules/uglify-js/lib/parse.js:204:11)
at croak (/home/hoylemd/code/Javascript/nodejs/simplewebsite/node_modules/jade/node_modules/with/node_modules/uglify-js/lib/parse.js:636:9)
at token_error (/home/hoylemd/code/Javascript/nodejs/simplewebsite/node_modules/jade/node_modules/with/node_modules/uglify-js/lib/parse.js:644:9)
at expect_token (/home/hoylemd/code/Javascript/nodejs/simplewebsite/node_modules/jade/node_modules/with/node_modules/uglify-js/lib/parse.js:657:9)
at expect (/home/hoylemd/code/Javascript/nodejs/simplewebsite/node_modules/jade/node_modules/with/node_modules/uglify-js/lib/parse.js:660:36)
at expr_atom (/home/hoylemd/code/Javascript/nodejs/simplewebsite/node_modules/jade/node_modules/with/node_modules/uglify-js/lib/parse.js:1112:17)
at maybe_unary (/home/hoylemd/code/Javascript/nodejs/simplewebsite/node_modules/jade/node_modules/with/node_modules/uglify-js/lib/parse.js:1287:19)
at expr_ops (/home/hoylemd/code/Javascript/nodejs/simplewebsite/node_modules/jade/node_modules/with/node_modules/uglify-js/lib/parse.js:1322:24)
at maybe_conditional (/home/hoylemd/code/Javascript/nodejs/simplewebsite/node_modules/jade/node_modules/with/node_modules/uglify-js/lib/parse.js:1327:20)
这并没有告诉我哪里出了问题。我没有听说过关于 Jade 的好东西,但是一个不告诉我任何关于语法错误的模板引擎总比没用好。任何人都可以阐明正在发生的事情吗?
最佳答案
我可以建议您在工作流程中使用 Grunt。 Grunt JADE 的输出是这样的:
Running "jade:compile" (jade) task
TypeError: src/jade/index.jade:20
18| div.page-header
19|
> 20| h3(.text-muted Header Here
21|
22| div.row
23| div.col-xs-12
要使用Grunt,你可以查看:www.gruntjs.org
要将 Jade 与 Grunt 一起使用,请检查:https://npmjs.org/package/grunt-contrib-jade
关于node.js - 我可以让我的 nodejs/express/jade 堆栈报告合理的语法错误吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17733808/