Answer the question
In order to leave comments, you need to log in
Why can't remove require.cache in express route?
It is necessary that with each new request, the test module is executed anew.
But when the file is changed, its original contents are executed.
I would like to solve the problem without restarting the server.
test module for module.exports = 'hello from view'
express updates
var express = require('express');
var app = express();
app.get('/', function (req, res) {
require.cache = []
let html = require('./test')
res.send(html);
});
app.listen(3000, function () {
console.log('Example app listening on port 3000!');
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question