Disable pug debug output with express.js web app
- 24 May 2017: Post was created (diff)
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')
References
- source for
pug.__express
- http://expressjs.com/en/4x/api.html#app.engine
- https://pugjs.org/api/reference.html
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.