glamorous-printer-6654805/11/2019, 5:33 AM
or any other single character 😄. It just makes reading the code harder even if it’s somewhat clear from the surrounding context what the c stands for (but consumes more brain CPU :-P). In your example I would call this variable
instead. 2. You can turn
import fs = require('fs');
. Just looks more ES6 native 😉 Coming to your actual problem: In line 15 you’re loading the merged config by calling require(‘config’). This will load the merged config based on your environment variables during the first .forEach loop iteration. However in the second loop iteration - despite you having changed the environment variables - the
import * as fs from 'fs'
call will return exactly the same thing as in the first one. In general in node.js multiple calls of require(‘asdf’) will always return the exact same thing (this also applies to ES6 imports
for that matter). This is described in further detail here: https://nodejs.org/api/modules.html#modules_caching . I haven’t tried it out myself but it looks like you should be able to use https://github.com/lorenwest/node-config/wiki/Using-Config-Utilities#loadfileconfigsdirectory (e.g.
import ... from 'asdf'
instead of the plain
to load the merged config without experiencing the caching problem.