Setting Up a Node.js Express Server from Scratch

A step-by-step guide to creating a basic Node.js server using Express.

Jacob Evenson Mon Feb 16 2026 18:00:00 GMT-0600 (Central Standard Time)

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:

npm init -y

This creates a package.json file that manages your project dependencies.


Step 2: Install Express

Install Express using npm:

npm install express

Step 3: Create the Server File

Create a file called app.js.

Add the following code:

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:

node app.js

Then visit:

http://localhost:8080

You should see "Hello, world!" in your browser.


Understanding the Code


Why Use Express?

Express simplifies:

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!