utside the browser and even build your own web servers. In this post, we’ll walk through setting up Node.js on your computer and writing your very first “Hello World” program.
🛠 Step 1: Install Node.js
There are two main ways to install Node.js:
- Quick Start (Beginner Friendly): Download the official Node.js LTS installer. This is the fastest way to get started.
- Developer Way (Recommended): Use Node Version Manager (nvm), which lets you install and switch between multiple versions of Node.js — something you’ll need as you grow into a developer.
👉 In this post, we’ll keep it simple and use the official installer so you can jump straight into writing code. If you want to set things up like a pro from the beginning, check out my full guide here: Node Version Manager (nvm): A Developer’s Guide to Installing and Managing Node.js Versions.
Now, let’s install Node.js using the quick start method:
- Go to the Node.js download page.
- Download the latest LTS (Long Term Support) version (recommended for beginners).
- Run the installer. If you see an option to also install extra tools (like Python and Visual Studio via Chocolatey), select it — it saves time later.
👉 To check if it worked, open your terminal/command prompt and type:
node -v
npm -v
You should see the installed versions of Node.js and npm (the Node.js package manager).
📂 Step 2: Create a Project Folder
Let’s create a folder to keep your code organized. In your terminal:
mkdir my-first-node-app
cd my-first-node-app
👩💻 Step 3: Write Your First Program
Inside your folder, create a file named app.js. Add this code:
// app.js
console.log("Hello, World from Node.js!");
Now run it:
node app.js
✅ You should see this output in your terminal:
Hello, World from Node.js!
🌐 Step 4: Create a Simple Web Server
Let’s go a step further and make Node.js serve a web page. Replace the code in app.js with this:
// app.js
const http = require("http");
// Create a server
const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader("Content-Type", "text/plain");
res.end("Hello, World from Node.js Server!\n");
});
// Start the server on port 3000
server.listen(3000, () => {
console.log("Server running at http://localhost:3000/");
});
Run it again:
node app.js
Now open your browser and go to http://localhost:3000.
🎉 You’ll see your first Node.js web page!
🧠 How It Works
console.logprints messages to your terminal.http.createServercreates a simple server.server.listen(3000)tells it to listen on port 3000.
✅ Key Takeaway
With just a few steps, you’ve:
- Installed Node.js
- Written a basic program
- Built a simple web server
This is the foundation of Node.js development. From here, you can start exploring frameworks like Express.js or even full-stack solutions like Next.js to make server building even easier.