Node.js Fundamentals — Complete Guide
Node.js Fundamentals — Complete Guide: free step-by-step lesson with examples, common mistakes, and interview tips — part of MEAN Stack Tutorial on Toolliyo Academy.
On this page
MEAN Stack Tutorial · Lesson 31 of 100
Node.js Fundamentals
Stack → Projects
Stack · 1 — Pieces · ~6 min · MEAN — Node.js & Express
What is this?
Node.js runs JavaScript on the server with modules, npm packages, and a non-blocking I/O model powering MeanVerse Express APIs.
Why should you care?
Understanding require/import, process.env, and the module system prevents mysterious startup failures in production.
See it live — copy this example
Paste into your MeanVerse project (Angular + Express + MongoDB), then run with ng serve / node / mongosh as noted.
// api/src/server.ts
import http from 'node:http';
import { env } from './config/env.js';
const server = http.createServer((_req, res) => {
res.writeHead(200, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({ service: 'meanverse-api', uptime: process.uptime() }));
});
server.listen(env.port, () => {
process.stdout.write(`Listening on ${env.port}\n`);
});
What happened?
- node:http is built-in.
- process.uptime() shows seconds since start.
- env.port centralizes config — same pattern before adding Express.
Practice next
- Run node -e "console.log(process.version)".
- Create server.ts and start with ts-node or node.
- Import a local module with relative path.
- Switch to createServer with Express app.listen delegate.
- Log process.memoryUsage() after warm traffic.
Remember
Node = V8 + libuv + standard libraries. Modules isolate code; npm manages dependencies. process.env drives configuration.
API health probe
Kubernetes liveness checks MeanVerse /health endpoint.
Outcome: Minimal Node handler proves process is alive.
Interview prep for this lesson
Practice these questions aloud after reading—each links to a full structured answer.
Sign in to ask a question or upvote helpful answers.
No questions yet — be the first to ask!