# 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:

1.  Go to the official Node.js website: [https://nodejs.org](https://nodejs.org)
    
2.  Download the **LTS (Long-Term Support)** version
    
3.  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:

```bash
node -v
```

You should see a version number like:

```bash
v24.x.x
```

Now check npm:

```bash
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:

```bash
node
```

You’ll see something like:

```bash
>
```

### Try this:

```js
console.log("Hello from REPL");
```

Output:

```bash
Hello from REPL
```

### Exit REPL:

```bash
.exit
```

or press:

```bash
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:

```bash
app.js
```

### Step 2: Add code

```js
console.log("Hello, Node.js!");
```

* * *

## 5\. Running Your Script

To execute the file, navigate to its directory in terminal and run:

```bash
node app.js
```

### Output:

```bash
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`

```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

```bash
node app.js
```

### Step 3: Open browser

Go to:

```bash
http://localhost:3000
```

### Output:

```bash
Hello World from Node.js Server
```

* * *

## What’s Happening Behind the Scenes?

*   `require("http")` → imports Node’s built-in HTTP module
    
*   `createServer()` → creates a server instance
    
*   `req` → incoming request object
    
*   `res` → response object sent back to client
    
*   `listen(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 `node` command
    
*   You 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 (`fs` module)
    
*   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 👍
