Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ho can i make my nodejs/express/jade stack report sensible syntax errors?

Tags:

node.js

pug

I'm running Jade as a templating engine with Express/node.js, and whenever I get a syntax error in my .jade file, i get a report like this:

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)

This doesn't tell me anything about what went wrong. I've heard nothing bug good things about Jade, but a templating engine that doesn't tell me anything about a syntax error is little better than useless. Can anyone shed some light on what's going on?

like image 895
hoylemd Avatar asked Nov 03 '22 18:11

hoylemd


1 Answers

I can suggest you to use Grunt for your workflow. The output from Grunt JADE is something like this:

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

To use Grunt, you can check: www.gruntjs.org

And to use Jade with Grunt, check: https://npmjs.org/package/grunt-contrib-jade

like image 159
Pedro Baptista Afonso Avatar answered Nov 11 '22 04:11

Pedro Baptista Afonso