-
Notifications
You must be signed in to change notification settings - Fork 499
Strict Mode
Strict Mode was added in node-config 1.9.0.
Several checks are made to make sure that NODE_ENV
and NODE_APP_INSTANCE
values are sensible. If something appears to be unsafe or ambiguous, a warning will always be issued. If NODE_CONFIG_STRICT_MODE
is set to 'true' or '1' in the environment, an exception will be thrown to ensure that the application doesn't start up with a configuration that might be broken.
If NODE_ENV
is set in the environment, we check if there is any file matching that name in the config/
directory containing valid syntax. You can create a file with the name matching the desired NODE_ENV
value: {NODE_ENV}.json
and include the contents '{}', which is an empty valid JSON object. If you are using YAML based config files, the file {NODE_ENV}.yml
must not be empty, place a comment or any valid YAML syntax in the file.
This could also indicate a problem with specifying your configuration directory or the file load order.
If NODE_APP_INSTANCE
is set in the environment, we check if there any file matching that name in the config/
directory. If there's actually no problem, create a file name matching the desired NODE_ENV
value: default-{NODE_APP_INSTANCE}.json
and include the contents '{}', which is an empty valid JSON object.
This could also indicate a problem with specifying your configuration directory or the file load order.
Files named default
and local
have a special place in the config loading order. Since we also support files simply named after NODE_ENV
we can't be sure whether a file named default
or local
was meant be represent one of these special files, or after your NODE_ENV. Without Strict Mode, these files could end up being loaded twice in the load order which is probably not what you want.
Therefore, please avoid setting NODE_ENV to the value 'local' or 'default'. It is better to use e.g. NODE_ENV=myhost and myhost.json as config.
Review this page
<>