问题
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