Consider the following file structure:
├─ log.js
├─ test.js
└─ file.json
log.js
exports a function that logs the contents of file.json
like :
// log.js
exports.logFile = () => {
console.log(require('./file.json'));
};
I'm calling this function every second in test.js
like so:
// test.js
setInterval(() => {
require('./log.js').logFile();
}, 1000);
Now, when I change file.json
while log.js
is running, none of my changes are reflected in the logs, i.e. it keeps printing the same (initial) value every second.
I fail to understand why this is happening, shouldn't it show the changes?