Answer to the question
KrakenJS does **not** log an error or warning when the NODE_ENV‑specific file (e.g., production.json) is missing. It silently falls back to the base config and its defaults, so production‑only settings such as view caching, strict error handling, and security middleware are not applied without any noticeable startup failure.
Likely explanation vs. confirmed facts
Likely explanation
The framework treats environment‑specific overlay files as optional because it uses the confit library for configuration merging. When an overlay file cannot be found, confit simply skips it and continues merging, which results in no log output by design.
Confirmed facts (from research)
- KrakenJS builds its configuration by merging
config/config.json with an optional overlay named after NODE_ENV (e.g., config/production.json).
- When the overlay file is absent,
confit does not throw or emit a prominent error; it resolves the merged config from the base file plus defaults.
- This silent fallback means production‑only toggles can revert to development defaults without any startup failure.
- KrakenJS provides no built‑in flag to make a missing environment file fatal; enforcement must be done in application or deployment code.
Steps to enforce presence of the environment‑specific file
- Pre‑start validation script: Before creating the Kraken app, check that the expected file exists.
const path = require('path');
const fs = require('fs');
const env = process.env.NODE_ENV || 'development';
const configPath = path.resolve(__dirname, 'config', `${env}.json`);
if (!fs.existsSync(configPath)) {
console.error(`Fatal: Missing environment‑specific config file: ${configPath}`);
process.exit(1);
}
// proceed to create Kraken app
const kraken = require('kraken-js');
const app = kraken();
app.listen(3000);
- CI/build artifact check: Add a step in your pipeline that fails if
config/production.json is not present in the built artifact or container image.
# Example CI step (bash)
if [ ! -f config/production.json ]; then
echo "ERROR: production.json missing in build artifact"
exit 1
fi
- Optional runtime assertion: After config resolution, assert that a production‑only setting has the expected value (e.g., view cache enabled).
if (app.get('view cache') !== true) {
console.error('Error: view cache not enabled – likely missing production config');
process.exit(1);
}
Missing diagnostic detail that could change the recommendation
To be absolutely certain about the silent‑fallback behavior, confirm the exact version of kraken-js (and its confit dependency) locked in your package-lock.json. If you are using a very old or patched version, the behavior might differ, and the validation steps above would still be safe but could be adjusted.