🚀 LEVEL UP TO SENIOR:Unlock 500+ Advanced Practical Challenges & Exercises.
🎓 COURSERA PARTNER:Earn professional Google, Meta, and IBM certificates to supercharge your resume.
HTML MASTER CLASS /// LEARN TAGS /// BUILD STRUCTURE /// SEMANTIC WEB /// HTML MASTER CLASS /// LEARN TAGS ///

Untitled Lesson

Total XP: 0|💻 backend XP: 0

Skill Matrix

UNLOCK NODES BY LEARNING NEW TAGS.

Select an unlocked node to view details root

Pascual Vila

Pascual Vila

Frontend Instructor // Code Syllabus

Common Pitfalls & Errors

The Error //

Committing a real .env file to version control

# .gitignore — add on day one, before any secrets exist .env .env.*.local

The Solution //

A .env file typically contains real secrets for at least local development. Once committed, those secrets live permanently in git history, retrievable even after the file is later deleted, unless history is explicitly rewritten. Add .env to .gitignore before the very first commit, and rotate any secret that was ever committed, even briefly.

The Error //

Importing a module that reads process.env before dotenv/config has run

// Wrong: db client reads process.env before dotenv runs import { connectDb } from "./db.js"; import "dotenv/config"; // Correct: dotenv runs first, always import "dotenv/config"; import { connectDb } from "./db.js";

The Solution //

dotenv only populates process.env once its config() function actually executes. If another module reads process.env at its own top-level (module load time) before that happens — common when import order is accidental rather than deliberate — it silently receives undefined for every variable. Always import dotenv/config as the literal first line of your application's entry file.

Continue Learning