I'm using nconf to handle configuration in my app. The way I'm setting it up is as follows:
nconf.env({
separator: '__',
whitelist: ['foo', 'bar']
})
.file('config.json')
It appears that I'm not able to modify values if they were obtained via an environment variable. For example,
console.log(nconf.get()); // {"foo":123,"bar":356}
nconf.set('foo', 789);
console.log(nconf.get()); // {"foo":123,"bar":356}
I have inspected the stores attribute of nconf and it seems to suggest that env variables are read-only?
console.log(nconf.stores);
/**
* { env:
* { type: 'env',
* store: { foo: [Object] },
* mtimes: { 'foo': 1372348332705 },
* readOnly: true, <-- here
* loadFrom: null,
* whitelist:
* ...
Is there a way to allow variables set via env variables to be modified at runtime? If I set values which were set using the config.json file I am able to modify values without any problems.
Any help much appreciated :-)