Raif
Raif

Reputation: 9249

node-config how can I dynamically set property

Using node-config, is there anyway to do

var config = require('config');
config.ip = someIp;

I need to get my ips dynamically and use them in my config. Is there anyway to do this?

I tried just setting it but it's a read only property. I also looked at the code but could not see a way to do it. Please don't make me change my config framework :(

thanks,

R

Upvotes: 2

Views: 2871

Answers (1)

Raif
Raif

Reputation: 9249

So I guess I found the answer. If you declare

process.env['ALLOW_CONFIG_MUTATIONS']=true;

Then you can use the set method on config values. To be specific, you can set 'ALLOW_CONFIG_MUTATIONS' to anything besides null or undefined and it should work.

Upvotes: 4

Related Questions