Can I require('app') in multiple modules?


#1

I’m building an app that has, of course, an app.js that contains all of the app flow bits, but I have a couple of additional cross-cutting modules (logging, config) that I need to include all over the place. These need to know the location of App.getPath('userData').

There are options, I know, but the lowest friction solution I currently have in place is to simply require('app') in my logger.js module and my config.js module. It’s still early, but so far there don’t seem to be any obvious issues. It does, however, feel like “bad form”.

Am I overthinking this? Maybe the form isn’t as bad as it feels? Are they dangers in doing this that I just haven’t bumped into yet? Looking for some guidance from experience on this one.

Thanks.


#2

Check out the node modules documentation about caching.