What is the Twelve-Factor App methodology as it applies to Node.js?

Why Interviewers Ask This

Interviewers ask this to evaluate whether you have the depth of knowledge needed to mentor others and lead technical decisions. The expected answer goes beyond definitions into practical implications and real-world consequences.

Answer

The Twelve-Factor App is a methodology for building scalable, maintainable, cloud-native applications. Applied to Node.js: (1) Codebase: one codebase in version control; (2) Dependencies: explicitly declared in package.json — never rely on global packages; (3) Config: store config in environment variables (process.env) — not hardcoded; (4) Backing services: treat databases, queues as attached resources via URLs in config; (5) Build, release, run: separate stages — npm run build, tag release, node dist/app.js; (6) Processes: execute as stateless processes — no sticky sessions, no local file storage; (7) Port binding: self-contained HTTP service — app.listen(process.env.PORT); (8) Concurrency: scale via process model — cluster/PM2; (9) Disposability: fast startup, graceful shutdown on SIGTERM; (10) Dev/prod parity: minimize differences between environments — use Docker; (11) Logs: treat logs as event streams — write to stdout, let infrastructure route them; (12) Admin processes: run one-off admin tasks (migrations, scripts) in the same environment as the app.

Common Mistake

Candidates often give textbook answers here. Interviewers are more impressed when you relate the concept to a specific problem you solved in a real Node.js project.