Setting Up Your First Node.js Application Step-by-Step
Getting started with Node.js is the first step toward building backend systems, APIs, and full-stack applications using JavaScript. This guide walks you through the complete setup process—from installation to running your first server—without using any frameworks.
1. Installing Node.js
Node.js is a JavaScript runtime that allows you to execute JavaScript outside the browser.
Steps:
Go to the official Node.js website: https://nodejs.org
Download the LTS (Long-Term Support) version
Install it using the default settings
This installation also includes npm (Node Package Manager), which you’ll use later for managing dependencies.
2. Verifying Installation
Once installed, you need to confirm that Node.js is correctly set up.
Open your terminal (or command prompt) and run:
node -v
You should see a version number like:
v24.x.x
Now check npm:
npm -v
If both commands return versions, your setup is successful.
💡 Tip: If you ever forget common commands or want quick one-liner solutions for JavaScript/Node tasks, platforms like Practica JS can be very handy for fast reference and practice.
3. Understanding Node REPL
REPL stands for:
Read – Evaluate – Print – Loop
It’s an interactive environment where you can execute JavaScript code line-by-line.
Start REPL:
node
You’ll see something like:
>
Try this:
console.log("Hello from REPL");
Output:
Hello from REPL
Exit REPL:
.exit
or press:
Ctrl + C (twice)
Why REPL matters:
Quick testing of JavaScript code
Debugging logic
Learning Node interactively
4. Creating Your First JavaScript File
Now let’s move from interactive mode to writing actual scripts.
Step 1: Create a file
Create a file named:
app.js
Step 2: Add code
console.log("Hello, Node.js!");
5. Running Your Script
To execute the file, navigate to its directory in terminal and run:
node app.js
Output:
Hello, Node.js!
This is your first Node.js execution 🎉
6. Writing Your First “Hello World” Server
Now let’s create a basic HTTP server using Node’s built-in module (no frameworks).
Step 1: Update app.js
const http = require("http");
const server = http.createServer((req, res) => {
res.write("Hello World from Node.js Server");
res.end();
});
server.listen(3000, () => {
console.log("Server running at http://localhost:3000/");
});
Step 2: Run the server
node app.js
Step 3: Open browser
Go to:
http://localhost:3000
Output:
Hello World from Node.js Server
What’s Happening Behind the Scenes?
require("http")→ imports Node’s built-in HTTP modulecreateServer()→ creates a server instancereq→ incoming request objectres→ response object sent back to clientlisten(3000)→ server starts listening on port 3000
Key Takeaways
Node.js allows you to run JavaScript outside the browser
REPL is useful for quick experimentation
Scripts are executed using the
nodecommandYou can create a basic server without any frameworks
Node’s core modules (like
http) are powerful enough for fundamentals
What’s Next?
Once you’re comfortable with this setup, you can move on to:
File system operations (
fsmodule)Handling routes manually
Understanding asynchronous behavior in Node.js
If you want, I can also:
Add SEO title + meta description
Suggest Hashnode tags
Create a cover image prompt
Or help you make this stand out from others in your cohort
Just tell me 👍