I'm trying to access my config.js file in all modules of my project but I can't even though the config file is defined as global.
Here's my packaging:
in the server.js I have defined:
global.config = require('./app/config');
I can access the properties of config in server.js but when I try to use config
in other files such as user.js I get this error:
config is not defined
I don't know how to fix the way I'm defining this global variable.
it doesn't make any sense but when I moved the global variable above the variable which contained the router it worked.
global.config = require("./app/config");
const routeHandler = require('./app/routes/index');
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments