Disable pug debug output with express.js web app

Revision history
Tags: pug express.js javascript

While developing an express app and using pug, as long as NODE_ENV !== 'production' pug outputs function bodies to stdout. I find that pretty annoying, and I only want it to output stuff to console when theres actually an error.

Can be done by setting a custom engine function for pug

app.engine('pug', (path, options, fn) => {
  options.debug = false
  return pug.__express.call(null, path, options, fn)
app.set('view engine', 'pug')


If you have any comments or feedback, please send me an e-mail. (stig at stigok dotcom).

Did you find any typos, incorrect information, or have something to add? Then please propose a change to this post.

Creative Commons License This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.