I have a javascript file and in it I require another file that has a variable that changes.
main.js
let num = require("./extra").num
extra.js
let num = 5;
setInterval(() => {
if (num > 0) {
num--;
}
console.log(num);
}, 1000);
module.exports = {
num
};
Now in the main.js file that variable num is always 5 and never changes. What do I need to do to get it updated all the time?
Note: I'm declaring the variable in main.js AFTER the variable changes so it shouldnt't be 5
from Required module does not update when the variable inside that module changes
No comments:
Post a Comment