首先,我尝试遵循这个问题(但适应了 Express 3.0):
app.use(function(err, req, res, next) {
console.error('Middleware exception:' + err.stack);
next(err);
});
但是,无论我将它放在中间件链的哪个位置,在app.use(lessMiddleware);
(从require('less-middleware')
)之前或之后,我仍然会得到:
GET /? 304 44ms
source : <my path>/style.less
dest : <my path>/style.css
read : <my path>/style.less
DEBUG:
DEBUG: <my path>/node_modules/less-middleware/node_modules/less/lib/less/parser.js:385
throw new(LessError)(e, env);
^
DEBUG: [object Object]
DEBUG: Program node app.js exited with code 1
亲爱的读者,如何解决这个问题?我想要:
- 显示错误堆栈跟踪
- 显示服务器错误页面而不是崩溃