Explore essential NodeJS programs covering fundamental concepts and syntax examples — HTTP servers, file system operations, streams, event emitters, promises, worker threads, and Express.js basics — with expected output to verify your code.
Node.js is an open-source, cross-platform JavaScript runtime environment built on V8 engine, designed for high-performance server-side web development. Ideal for backend engineers, bootcamp students, and API developers.
Last updated: September 2026 · 20 examples · Node.js v20/v22 Compatible
Uses the built-in HTTP module to create a simple web server listening on port 3000.
Program (Node.js)
const http = require("http");
const server = http.createServer((req, res) => {
res.writeHead(200, { "Content-Type": "text/plain" });
res.end("Hello from Node.js HTTP Server!\n");
});
const PORT = 3000;
console.log(`Server running at http://localhost:${PORT}/`);
Expected Output
Server running at http://localhost:3000/
Frequently Asked Questions
You can write and execute Node.js scripts instantly using our Online Node.js Compiler. For local execution, install Node.js from nodejs.org and run node filename.js in your terminal.
Essential built-in modules include http (web servers), fs (file system), path (directory paths), os (system metadata), events (EventEmitter), crypto (hashing), and url (URL parsing).
Node.js operates on a single-threaded Event Loop backed by libuv. Heavy I/O tasks like reading files or database queries run in background worker threads, notifying the main thread via callbacks, Promises, or async/await.
Yes! Understanding Node.js core modules and async control flow is the foundation for building microservices, REST APIs, and full-stack applications with Express, NestJS, and Fastify.