Untitled Lesson
Skill Matrix
UNLOCK NODES BY LEARNING NEW TAGS.
Which built-in Node.js module should you use to guarantee that your folder paths are constructed with the correct slash character (`/` vs `\`), regardless of whether the server is running on Windows or Linux?
š» Code Challenge | +75 XP
Write the Node.js/Backend code snippet to implement a Node Internal Modules pipeline. Include the setup and basic execution steps.
You are reviewing a Node Internal Modules pipeline and the output is incorrect. Reorder the following pipeline stages in the correct logical order to fix the bug: Input Data, Process, Output.
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 //
Using fs.readFileSync (or any *Sync fs call) inside a request handler
// Wrong: blocks every user's request while this one reads the disk
app.get('/report', (req, res) => {
const data = fs.readFileSync('./report.csv');
res.send(data);
});
// Correct
import fs from 'node:fs/promises';
app.get('/report', async (req, res) => {
const data = await fs.readFile('./report.csv');
res.send(data);
});The Solution //
Every *Sync method in the fs module blocks Node's single thread until the operation finishes, freezing the entire server for every concurrent user, not just the one who triggered it. Always use fs/promises (or the callback API) inside anything that runs per-request; reserve *Sync calls for one-time startup code that runs before the server starts accepting connections.
The Error //
Hardcoding OS-specific path separators instead of using the path module
// Wrong: breaks on Linux/macOS deployment
const file = __dirname + '\\views\\index.html';
// Correct: works everywhere
import path from 'node:path';
const file = path.join(__dirname, 'views', 'index.html');The Solution //
Concatenating strings with a literal backslash (Windows) or forward slash (Linux/macOS) to build file paths works on the developer's machine but breaks the moment the code runs on a different OS ā a very common surprise when deploying a Windows-developed app to a Linux container or server. Always build paths with path.join() or path.resolve(), which use the correct separator for whatever OS the code is actually running on.