change jade always require node.js restart then can verify the change

蓝咒 提交于 2019-12-29 09:14:11

问题


I'm using Jade as template engine at node.js. I have to stop node.js and start whenever I made changes to Jade file so I can verified the change. Is there tool or a way that if I made change to Jade I don't need to restart node.js app?


回答1:


Changes to Jade templates should be picked up automatically after you reload the page, at least in development mode.

If not, then the most likely cause is that view caching is enabled in Express, which is the default if the NODE_ENV environment variable is set to production, or caching is explicitly enabled.

To explicitly disable view caching, you can use this:

var app = express();
...
app.set('view cache', false);
...

However, this will carry a performance impact when you're running in production, as the template file will be processed for each request. Therefore, you should really try to find out why exactly Express is caching your templates (as said, the most likely culprit is NODE_ENV not being set correctly for a development environment).



来源:https://stackoverflow.com/questions/33798788/change-jade-always-require-node-js-restart-then-can-verify-the-change

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!