Reputation: 1129
I created a generic npm package which has my business logic, but I need some google cloud storage information that is in my config files. How can I access this file, if my package is in my node_modules folder? What would be a good solution for that?
this is the structure:
-config
-google_storage_config
-node_modules
-package
-serviceWhichNeedsThatConfig
Upvotes: 1
Views: 566
Reputation: 4316
Based on your folder structure, we will assume your path to the config will be ../../../config/google_storage_config
, since node_modules/package/serviceWhichNeedsThatConfig
should always be in the root directory.
Now, to access any variables from this config file, simply include the following code in the serviceWhichNeedsThatConfig
,
var config = require('../../../config/google_storage_config');
console.log(config.myVariable);
Upvotes: 1
Reputation: 1764
Hi~Have you tried require
?
var config = require('../../config/google_storage_config');
Upvotes: 0