const fs = require('node:fs');
const fs2 = require('fs'); // still works, older style
Topics
40
Advanced Node.js
Architecture & Design Patterns
Async Patterns
Authentication & Authorization
Authentication & Authorization (JWT, OAuth, Passport)
Background Jobs & Queues
Caching
Caching with Redis
Child Processes & Process Management
CLI Tools & Scripting with Node.js
Cloud & DevOps
Clustering & Worker Threads
Core Node.js Modules
Databases
Databases & ORMs (MongoDB/Mongoose, SQL/Sequelize)
Debugging & Diagnostics
Deployment & Process Managers (PM2)
Docker & Containerization for Node.js
Docker & Deployment
Email & Notifications
Environment Variables & Configuration
Error Handling
Event Loop & Non-blocking IO
Events & EventEmitter
Express & Middleware
File System & File Processing
File System (fs) Module
File Uploads & Media Processing
Git & Project Management
Global Objects & the process Object
GraphQL
GraphQL with Node.js
HTTP & HTTPS Modules
HTTP & Web Servers
Logging & Monitoring
Message Queues (RabbitMQ & Kafka)
Microservices Architecture with Node.js
Node.js Fundamentals & Runtime Architecture
Path & OS Modules
Performance Optimization & Profiling
Core Node.js Modules
15 questions found
The node: prefix explicitly signals a built-in core module rather than a third-party package -- introduced partly to remove ambiguity in module resolution and support scenarios where explicitly distinguishing core modules from userland packages matters; older unprefixed requires still work for compatibility.
Real-world example
A team adopts the node: prefix so a linter rule can flag accidental shadowing of a core module name by a local file, making core-module imports visually unambiguous.
Modules (CommonJS/ESM);File System (fs) Module
What is the util module's inspect() function used for, and how does it relate to how console.log() displays objects?
Beginnerutil.inspect() converts a value into a formatted, human-readable string, including nested objects -- it's what console.log() uses internally (rather than JSON.stringify, which can't handle circular references or non-JSON types), and can be called directly for custom formatting needs like controlling nesting depth.
const obj = { name: 'Alice', nested: { deep: { value: 42 } } };
console.log(util.inspect(obj, { depth: 1, colors: true }));
Real-world example
A logging utility uses util.inspect() with a bounded depth to safely log deeply nested request objects without crashing on a circular reference, which JSON.stringify would throw on.
Debugging & Diagnostics;JSON & Data Serialization
What does the node:path module provide, and why should you always use it instead of manually concatenating file path strings?
IntermediateThe path module provides platform-aware utilities -- join(), resolve(), dirname(), extname() -- that correctly handle the difference between path separators on different OSes, whereas manual string concatenation with a hardcoded '/' would break on Windows.
const filePath = path.join(__dirname, 'data', 'users.json');
console.log(path.extname(filePath));
Real-world example
A CLI tool that manually concatenated paths worked on macOS but broke on Windows until every path operation was replaced with path.join(), which uses the correct separator per OS.
File System (fs) Module;CLI Tools & Scripting with Node.js
What does the node:crypto module provide, and what's the difference between hashing and encryption?
Intermediatecrypto provides hashing (createHash), symmetric/asymmetric encryption, HMAC signing, and secure random generation. Hashing is one-way, producing a fixed-size fingerprint that can't be reversed; encryption is reversible, transforming data into ciphertext decryptable back to plaintext given the correct key.
const hash = crypto.createHash('sha256').update('some data').digest('hex');
const cipher = crypto.createCipheriv('aes-256-gcm', key, iv);
Real-world example
A file-integrity checker computes a SHA-256 hash to verify a download wasn't corrupted, while a separate feature encrypts stored API credentials with AES-256-GCM so they can be decrypted later.
Security;Authentication & Authorization (JWT
OAuth
Passport)
What does the URL/URLSearchParams API provide, and why is it generally preferred over the older querystring module today?
BeginnerURL and URLSearchParams (globally available, matching the browser API) provide a complete, spec-compliant way to parse a URL and manipulate query strings, handling edge cases like encoding more consistently than the legacy querystring module.
const url = new URL('https://example.com/search?q=nodejs');
console.log(url.searchParams.get('q'));
const params = new URLSearchParams();
params.append('name', 'Alice');
Real-world example
An HTTP client builds request query strings using URLSearchParams rather than manual concatenation, automatically getting correct percent-encoding of special characters.
HTTP & HTTPS Modules;RESTful API Design with Express
What does the node:assert module provide, and how does it differ in purpose from a full testing framework?
Intermediateassert provides basic assertion functions that throw an AssertionError when unmet -- a low-level building block used as the assertion layer inside test suites, but it doesn't provide test organization, running, or reporting the way a full framework like Jest does.
assert.strictEqual(2 + 2, 4);
assert.deepStrictEqual({ a: 1 }, { a: 1 });
Real-world example
A team using node:test pairs it with node:assert for assertions, avoiding an external assertion library for a minimal, dependency-light testing setup.
Testing with Jest
Mocha & the Node Test Runner;Error Handling
What is the node:stream module's Transform stream, and how does it differ from a Readable or Writable stream?
AdvancedA Transform stream is both readable and writable, taking input, transforming it (via a required _transform() method), and making the result readable out the other side -- unlike a plain Readable or Writable, it sits naturally in the middle of a pipeline, standard for compression, encryption, or format conversion as streaming steps.
const uppercaseTransform = new Transform({
transform(chunk, encoding, callback) {
this.push(chunk.toString().toUpperCase());
callback();
},
});
readableStream.pipe(uppercaseTransform).pipe(writableStream);
Real-world example
A log-processing pipeline pipes raw log lines through a custom Transform that redacts sensitive fields, processed incrementally without loading the entire file into memory.
Streams & Buffers;File System & File Processing
os exposes OS-level info: platform() (OS name), cpus() (core details), totalmem()/freemem() (memory stats), homedir(), and tmpdir() -- useful for cross-platform scripts, sizing worker pools, and diagnostic logging.
console.log('Platform:', os.platform());
console.log('Free memory (GB):', (os.freemem() / 1e9).toFixed(2));
Real-world example
A monitoring script logs os.freemem() and os.cpus().length to help diagnose whether periodic slowdowns stem from low memory or insufficient CPU cores.
Path & OS Modules;CLI Tools & Scripting with Node.js
What does the node:zlib module provide, and how would you use it to compress an HTTP response?
Intermediatezlib provides compression/decompression (gzip, deflate, Brotli) -- commonly used to compress HTTP responses reducing bandwidth, with Accept-Encoding indicating client support, though in Express this is typically handled via the compression middleware.
fs.createReadStream('large-file.txt').pipe(zlib.createGzip()).pipe(fs.createWriteStream('large-file.txt.gz'));
app.use(require('compression')());
Real-world example
An API serving large JSON payloads adds the compression middleware, reducing typical response sizes by 70-80% and improving load times on slower connections.
HTTP & HTTPS Modules;Performance Optimization & Profiling
What is the node:vm module, and what are the security implications of using it to execute untrusted code?
Advancedvm compiles and runs JavaScript within a separate V8 context, often for sandboxing -- but its isolation is not a genuine hardened security boundary, since code running inside can, through known techniques, escape into the surrounding process in certain configurations, so it shouldn't be the sole defense for truly untrusted code.
vm.createContext(context);
vm.runInContext('result = 2 + 2;', context);
Real-world example
A low-code platform initially ran user formula scripts via vm alone, but moved to a separate resource-limited child process after a security review found vm's isolation alone insufficient.
Security;Child Processes & Process Management
Showing 1–10 of 15