Setting Up Your First Node.js Application Step-by-Step

Introduction
Imagine buying your very first guitar.
You’re excited.
You’re motivated.
You’re already imagining yourself performing dramatic solos in front of thousands of fans.
Then reality arrives.
You stare at:
cables
buttons
confusing setup screens
something called “drivers”
And suddenly your musical career pauses before the first note.
That’s exactly how many beginners feel when starting with:
Node.js
The good news?
Setting up Node.js is actually much simpler than it looks.
Once everything is installed properly, you can start building real JavaScript applications directly on your computer.
In this guide, you’ll learn:
how to install Node.js
how to check installation
what Node REPL is
how to create your first JavaScript file
how to run Node scripts
how to build your first Hello World server
And yes, by the end, you’ll officially become someone who runs JavaScript outside the browser.
Which feels oddly powerful.
Let’s set things up.
What Is Node.js?
Before installing anything, let’s quickly understand what Node.js actually is.
Node.js allows JavaScript to run:
Outside the browser
That means JavaScript can now:
create servers
read files
build APIs
handle databases
run backend applications
Think of Node.js like giving JavaScript a new job.
Before:
JavaScript worked only in browsers
After Node.js:
JavaScript can work on servers too
Installing Node.js
The first step is installing Node.js.
Step 1: Visit Official Node.js Website
Go to:
https://nodejs.org
You’ll usually see two versions:
LTS (Recommended)
Current
For beginners:
Install the LTS version
LTS means:
Long Term Support
More stable.
Less chaos.
Always appreciated.
Step 2: Download Installer
Choose installer based on your operating system.
Node.js supports:
Windows
macOS
Linux
The installation process is mostly straightforward:
Next → Next → Install → Finish
The universal software ritual.
Step 3: Verify Installation
After installation, open terminal or command prompt.
Run:
node -v
Output example:
v22.1.0
This confirms Node.js installed successfully.
Checking npm Installation
Node.js also installs:
npm
(Node Package Manager)
Check it using:
npm -v
Output example:
10.5.0
npm helps install libraries and tools later.
Very important.
Very useful.
Very capable of ruining weekends if dependencies break.
Understanding the Terminal
The terminal is basically a text-based control panel for your computer.
Instead of clicking buttons visually, you type commands.
At first it feels intimidating.
Eventually it becomes strangely addictive.
Understanding Node REPL
Once Node.js is installed, you can start:
Node REPL
REPL stands for:
Read
Evaluate
Print
Loop
Sounds fancy.
But conceptually it simply means:
“Interactive JavaScript playground inside terminal.”
Starting REPL
Open terminal and type:
node
You’ll see something like:
>
Now you can run JavaScript directly.
Example:
2 + 2
Output:
4
Why REPL Is Useful
REPL is perfect for:
testing code quickly
learning JavaScript
debugging ideas
experimenting safely
Think of it like a sandbox for JavaScript.
You try things instantly without creating files.
Example Inside REPL
const name = "Rahul";
console.log(name);
Output:
Rahul
Very useful for beginners.
Exiting REPL
To exit:
.exit
or press:
CTRL + C twice
Simple.
Creating Your First JavaScript File
Now let’s create an actual Node.js program.
Step 1: Create Folder
Create a folder anywhere.
Example:
my-first-node-app
Step 2: Create File
Inside folder, create:
app.js
.js means JavaScript file.
Writing Your First Node.js Program
Open app.js and write:
console.log("Hello Node.js");
Save file.
Congratulations.
You officially created a Node.js program.
Tiny.
But powerful.
Like baby superheroes.
Running Script Using Node Command
Open terminal inside project folder.
Run:
node app.js
Output:
Hello Node.js
That’s JavaScript running directly through Node.js.
No browser needed.
This moment feels surprisingly satisfying for beginners.
Node Execution Flow
Understanding What Happened
When you ran:
node app.js
Node.js:
read your file
executed JavaScript code
printed output to terminal
Very straightforward.
Script → Runtime → Output Flow
Writing Your First Hello World Server
Now let’s do something exciting.
Build a tiny web server.
Step 1: Import HTTP Module
Create new file:
server.js
Add:
const http = require("http");
Node.js includes built-in modules like http.
No extra installation needed.
Step 2: Create Server
const server = http.createServer((req, res) => {
res.end("Hello World");
});
This creates a server.
Whenever someone visits it:
"Hello World"
gets returned.
Step 3: Start Server
Add:
server.listen(3000, () => {
console.log("Server running");
});
Complete code:
const http = require("http");
const server = http.createServer((req, res) => {
res.end("Hello World");
});
server.listen(3000, () => {
console.log("Server running");
});
Running the Server
In terminal:
node server.js
Output:
Server running
Now open browser and visit:
http://localhost:3000
You’ll see:
Hello World
And just like that…
You built your first backend server.
Tiny internet infrastructure unlocked.
Real-Life Analogy Recap
Node.js
The engine that runs JavaScript outside browser.
REPL
Practice playground.
app.js
Your actual JavaScript file.
node app.js
Starts the program.
Hello World Server
Your first mini web server.
Very beginner-friendly.
Very powerful milestone.
Common Beginner Mistake
Many beginners accidentally run:
node
instead of:
node app.js
One starts REPL.
The other runs your file.
Easy confusion initially.
Why Learning Setup Properly Matters
A lot of beginner frustration comes from setup problems, not coding itself.
Understanding:
terminal basics
file execution
Node runtime behavior
makes learning backend development dramatically easier later.
Strong foundations matter.
Even if they don’t feel exciting initially.
Unique Tip for Beginners
Create a dedicated folder for every small Node.js experiment.
Example:
node-practice
Keeping projects organised early prevents absolute desktop chaos later.
Future-you will genuinely appreciate this.
Final Thoughts
Setting up Node.js is the first major step into backend JavaScript development.
By installing Node.js, understanding REPL, creating JavaScript files, and running scripts through terminal, you unlock the ability to build real server-side applications.
At a high level:
Node.js runs JavaScript outside browser
REPL allows interactive testing
node filename.jsexecutes scriptsbuilt-in modules like
httphelp create servers
And once your first Hello World server runs successfully, backend development suddenly feels much more real and far less intimidating.