Setting Up Your First Node.js Application Step-by-Step
Source: Dev.to
Introduction
Imagine you’re a developer staring at a blank screen, buzzing with ideas for your dream web app, but you’re stuck at the very beginning—no runtime, no environment, no clue where to start. Sound familiar? Not anymore.
Node.js changes everything. What seemed impossible yesterday is now a simple command away. Node is the powerhouse JavaScript runtime that lets you run JS on the server side, powering giants like Netflix and LinkedIn. Whether you’re a CS student building a portfolio or a hobbyist dipping into full‑stack development, this guide walks you through every step to build your first Node.js app—no frameworks, just pure, hands‑on setup. By the end, you’ll have a “Hello World” server humming on your machine. Let’s dive in.
Installing Node.js: Setup with Platform Notes
Node.js installation is straightforward and consistent across operating systems. The golden rule? Use the official NodeSource binaries or your system’s package manager for the latest LTS (Long‑Term Support) version. This ensures stability for production‑like projects.
Step 1: Download from the Official Site (Universal Starting Point)
Head to nodejs.org and grab the LTS version.
| Platform | Installation instructions |
|---|---|
| Windows | 1. Download the .msi installer.2. Run it as Administrator (PowerShell or Command Prompt). 3. Follow the wizard and enable “Add to PATH”. 4. Restart your terminal. |
| macOS | 1. Download the .pkg installer.2. Double‑click, enter your password, and let it install. Homebrew users: brew install node |
| Linux (Ubuntu/Debian) | ```bash\ncurl -fsSL https://deb.nodesource.com/setup_lts.x |
| Linux (Fedora/RHEL) | bash\nsudo dnf install nodejs # or use the NodeSource repo similarly\n |
| NixOS / Nix environments | Add to configuration.nix:nix\nenvironment.systemPackages = with pkgs; [ nodejs ];\n\nThen run sudo nixos-rebuild switch. |
Pro tip: Avoid third‑party download sites to dodge malware. Installation usually takes 2–5 minutes.

Verifying Your Installation
Open a terminal (Command Prompt/PowerShell on Windows, Terminal on macOS/Linux/NixOS) and run:
node --version
npm --version
You should see something like v24.14.0 for Node and 11.9.0 for npm (your numbers may differ). npm is installed automatically with Node and is the Node Package Manager used to install additional libraries.

If the commands return version numbers, the runtime is ready to execute JavaScript outside the browser.
Demystifying the Node.js REPL: Your Interactive Playground
Before writing files, let’s explore the REPL. REPL stands for Read‑Eval‑Print Loop—Node’s built‑in interactive shell for testing code snippets on the fly. It works like a JavaScript console in your terminal: type code, hit Enter, see results instantly.
Launch it:
node
You’ll see the prompt change to >. Try the following:
> console.log('Hello, Node!')
Hello, Node!
> 2 + 2
4
> let x = 5; x * 3
15
Exit with Ctrl+C twice or type .exit.

The REPL is perfect for quick prototypes—debugging math logic, testing string methods, or exploring APIs before writing full scripts.
Creating and Running Your First JavaScript File
Now let’s move from the REPL to a real file.
-
Create a project folder
mkdir my-first-node-app cd my-first-node-app -
Open the folder in your editor (VS Code is recommended)
code . -
Create a file named
hello.js(you can also usetouch hello.jsin the terminal)// hello.js console.log('Hello from my first Node.js script!'); console.log('Node version:', process.version); -
Run the script
node hello.jsExpected output (your version may differ):
Hello from my first Node.js script! Node version: v20.12.2
Node reads the file, compiles it just‑in‑time, executes it in the V8 engine (the same engine that powers Chrome), and prints the result to stdout—no browser required.
Building a Hello World Server: Your First Server‑Side App
Server
Node.js excels at creating servers via its built‑in http module (no npm install required). Create a file named server.js with the following code:
// server.js
const http = require('node:http'); // CommonJS import – built‑in module
const server = http.createServer((req, res) => {
// Basic HTTP server
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('Hello World from Node.js Server!\n'); // Send plain‑text response
});
const port = 3000; // You can move this to a .env file (requires the `dotenv` package)
server.listen(port, 'localhost', () => {
// Server starts listening for incoming requests
console.log(`Server running at http://localhost:${port}/`);
});
Run the server
node server.js
You should see:
Server running at http://localhost:3000/
Open that URL in your browser and you’ll be greeted with “Hello World from Node.js Server!”.
Stop the server with Ctrl + C.
This simple example demonstrates Node’s event‑driven, non‑blocking architecture: the server continuously listens for requests and handles each one asynchronously.
Wrapping Up: From Zero to Node Hero
You’ve just gone from installing Node.js to running a live server—without any frameworks. This foundation lets you:
- Add Express for routing and middleware.
- Deploy to platforms like Vercel (my go‑to for portfolio projects).
- Showcase your work on GitHub.
As a third‑year CS student juggling Java back‑ends and Node experiments, I use this workflow daily—it’s empowering.
What’s your first project idea? Drop it in the comments!