Sharing & modifying a variable between multiple files node.js
Your problem is that when you do var count = require(‘./main.js’).count;, you get a copy of that number, not a reference. Changing count does not change the “source”. However, you should have the files export functions. Requiring a file will only run it the first time, but after that it’s cached and does not re-run. … Read more