Node.js Fundamentals
Introduction to Node.js
JavaScript Beyond the Browser
For a long time, JavaScript lived exclusively inside web browsers. It was the language that made web pages interactive—animating buttons, validating forms, and fetching data. But what if you could use that same language to build the server that delivers the web page in the first place? In 2009, this idea became a reality with the creation of Node.js.
Node.js is a JavaScript runtime built on Google’s open-source V8 JavaScript engine.
A "runtime" is simply an environment where code can be executed. Node.js provides the environment to run JavaScript on a server, a personal computer, or almost anywhere else outside a web browser. It uses the same V8 engine that powers Google Chrome, which is known for being incredibly fast and efficient at running JavaScript. This means you can write fast, scalable network applications—like web servers, APIs, and real-time chat apps—all using a language you might already know.
Why It's Different
The magic behind Node.js is its approach to handling tasks, particularly ones that involve waiting, like reading a file from a disk or getting data from a database. This is called I/O, or Input/Output.
Most server-side languages handle I/O requests synchronously, or one at a time. Imagine a chef who takes an order, cooks the entire meal, serves it, and only then takes the next customer's order. The line would get very long, very fast.
Node.js works asynchronously. It’s like a chef who takes an order, hands it to the kitchen staff, and immediately takes the next order. When a dish is ready, the kitchen sends a notification, and the chef serves it. This "non-blocking" model allows a Node.js server to handle thousands of connections at once without getting stuck waiting.
This event-driven, non-blocking model is what makes Node.js lightweight, efficient, and perfect for data-intensive, real-time applications that run across distributed devices.
Another major benefit is npm, the Node Package Manager. It's the world's largest software registry, a massive library of free, reusable code modules called "packages." Need to work with dates, connect to a database, or add user authentication? There's almost certainly a package for that, saving you countless hours of work.
Getting Started
Setting up your Node.js development environment is straightforward. First, you need to install Node.js itself.
Go to the official Node.js website, nodejs.org. You'll see two versions available for download:
- LTS (Long-Term Support): This is the recommended version for most users. It’s stable, reliable, and supported with bug fixes and security updates for an extended period.
- Current: This version has the latest features, but it might not be as stable. It's great for experimenting with new capabilities but generally not recommended for production applications.
Download the LTS installer for your operating system (Windows, macOS, or Linux) and run it. The installation wizard will guide you through the steps. Accepting the default options is fine.
Once installed, you can verify everything is working. Open your computer's terminal or command prompt and type the following commands, pressing Enter after each one:
node -v
This command checks the installed version of Node.js. You should see a version number like v20.11.1.
npm -v
This checks the version of npm, which is installed automatically with Node.js. You'll see another version number, like 10.2.4.
If both commands return a version number, you're all set. You now have the power of Node.js and its vast ecosystem of packages at your fingertips.

