Introduction
Node.js is a runtime environment that lets you run JavaScript on the server side — not just in the browser.
It’s fast, scalable, and widely used for building APIs, web servers, and real-time apps.
Prerequisites
Before you start:
-
Install Node.js (v18 or later): https://nodejs.org
-
Install Visual Studio Code or any text editor
-
Basic knowledge of JavaScript
Step 1 — Check Node Installation
Open your terminal or command prompt and run:
You should see the installed versions of Node.js and npm (Node Package Manager).
Step 2 — Create Your Project
Create a new folder:
Initialize a Node.js project:
This creates a package.json file to manage your project and dependencies.
Step 3 — Create a Simple App
Create a file named app.js:
Run it:
✅ Output:
Step 4 — Create a Simple HTTP Server
Replace your app.js content with:
Run:
Open http://localhost:3000 — you’ll see:
Step 5 — Use External Packages
Install a popular package (e.g. Express, a web framework):
Update your app.js:
Run again:
Visit http://localhost:3000 — you’ll see:
Step 6 — Auto Restart with Nodemon
Install Nodemon globally:
Run:
Now your server restarts automatically whenever you change your code.
Step 7 — Create a Simple API
Add this route or update app.js:
Try visiting:
👉 http://localhost:3000/api/users
✅ You’ll see a JSON response!
Step 8 — Summary
You just learned how to:
-
Run JavaScript with Node.js
-
Create an HTTP server
-
Use Express.js
-
Create a REST API
-
Auto-restart with Nodemon

