I
I
Igor2016-10-26 22:28:17
Node.js
Igor, 2016-10-26 22:28:17

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

1 answer(s)
S
SagePtr, 2016-10-26
@sterjakov

https://github.com/dwyl/decache

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question