简体   繁体   中英

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM