Untitled Lesson
Skill Matrix
UNLOCK NODES BY LEARNING NEW TAGS.
You check `if (process.env.DEBUG)` to decide whether to enable debug mode, and DEBUG is set to the string `"false"`. What happens?
💻 Code Challenge | +75 XP
Write a config.js module using Zod that validates PORT (number, default 3000), DATABASE_URL (required string URL), and NODE_ENV (enum of development/production/test), throwing a clear aggregated error if validation fails.
A production deploy is silently leaking full stack traces to end users in error responses. Reorder the steps to diagnose and fix the root cause.
Task: Reorder the blocks in logical sequence to solve the problem.
A.D.A. Interface
Adaptive Didactic Assistant

Pascual Vila
Frontend Instructor // Code Syllabus
The Error //
Comparing process.env.PORT directly as a number without converting it
// Wrong: string concatenation instead of addition
const nextPort = process.env.PORT + 1; // "30001", not 3001!
// Correct
const nextPort = Number(process.env.PORT) + 1; // 3001The Solution //
Every value in process.env is a string, with zero exceptions — process.env.PORT is always "3000", never the number 3000. Comparisons or arithmetic against it without explicit conversion (Number(), parseInt()) produce subtly wrong results or NaN.
The Error //
Deploying to production without setting NODE_ENV=production
// Wrong: NODE_ENV left unset in production
// Correct — set explicitly in your deploy platform/Dockerfile
ENV NODE_ENV=productionThe Solution //
Many frameworks, Express included, key core production behaviors off NODE_ENV, including whether detailed error stack traces are sent to clients. Leaving it unset (or accidentally "development") in production silently leaks internal error details and disables performance optimizations like view caching.