I have a directory that looks like this:
-- app/
|- models/
|- user.js
|- config.json
I want my user.js file to re
I dont think we need to discuss about this problem.
It is design this way for easy of developer.
If we require /config.json maybe there are alot config.json in the sub folder which will typically make it even harder to understand
-- app/
|- controller
|- config.json(2)
|- models/
|- user.js
|- config.json(3)
|- config.json(1)
Now tell me how you know which one config file you need to choose.
Solution:
user.js
var config1 = require('../config.json');
var config2 = require('../controller/config.json');
var config3 = require('./config.json');
if there are only one config you better put in the global variable and use it from there.