---
title: Setting Up a Node.js Express Server from Scratch
description: A step-by-step guide to creating a basic Node.js server using Express.
author: Jacob Evenson
published: 2026-02-17
---

# Setting Up a Node.js Express Server from Scratch

Node.js and Express make it easy to build web applications quickly. In this tutorial, I will walk through how to create a basic Express server from scratch.

---

## Step 1: Initialize a Project

First, create a new folder and initialize a Node project:

```bash
npm init -y
```

This creates a `package.json` file that manages your project dependencies.

---

## Step 2: Install Express

Install Express using npm:

```bash
npm install express
```

---

## Step 3: Create the Server File

Create a file called `app.js`.

Add the following code:

```js
const express = require('express');
const app = express();
const port = 3000;

app.get('/', (req, res) => {
  res.send('Hello, world!');
});

app.listen(port, () => {
  console.log(`Server running at http://localhost:${port}`);
});
```

---

## Step 4: Start the Server

Run the following command:

```bash
node app.js
```

Then visit:

http://localhost:8080

You should see "Hello, world!" in your browser.

---

## Understanding the Code

- `require('express')` imports the Express framework.
- `app.get()` defines a route.
- `req` represents the request object.
- `res` represents the response object.
- `app.listen()` starts the server.

---

## Why Use Express?

Express simplifies:
- Routing
- Middleware handling
- Static file serving
- Template rendering

It is widely used in production applications and is an essential tool for full-stack development.

---

## Conclusion

Setting up an Express server is simple but powerful. From here, you can expand into dynamic routes, APIs, database integration, and deployment. Happy coding!