KOSUNI KOREA
Korean News in English
Technology

Node.js Tutorial: Building a Web Server with Express

Published October 16, 2026 · 1 views
Node.js Tutorial: Building a Web Server with Express

Welcome

In the previous lesson, we introduced a real-time chat web application project and set up the development environment.

Starting from this lesson, we'll begin writing code.

The first step is to create a web server (Web Server) that receives user requests and displays web pages.

In this session, we'll build our first web server using Express, the most commonly used web framework in Node.js.


What is a Web Server?

When you enter a website address in your browser, it sends a request to the corresponding server.

The server processes the request and delivers files like HTML, CSS, and JavaScript back to the browser.

In short, a web server connects users with websites.

For example, consider entering this address in your browser:

http://localhost:3000

Your browser requests the page from the server,

and the server responds with HTML to display on the screen.

All future services we build will operate on this web server foundation.


About Express

You can create a web server using Node.js alone, but it may become lengthy and complex.

Express is a web framework designed to simplify this process.

With Express, you can build a web server with minimal code and easily implement features like:

  • Serving web pages

  • Developing APIs

  • URL management (Routing)

  • File uploads

  • Login handling

  • Middleware management

It's fair to say that most Node.js web projects today use Express.


Opening the Project Folder

Open the project folder created in the previous session using Visual Studio Code.

For example, let's assume your project name is:

chat-project

After opening the folder in VS Code, launch the terminal.


Installing Express

In the terminal, enter this command:

npm install express

After installation completes, new files and folders will appear in your project folder.

You'll see a structure like this:

chat-project
│
├── node_modules
├── package.json
├── package-lock.json

The node_modules folder stores all installed libraries.


Understanding package.json

Installing Express adds new entries to the package.json file.

For example, you'll see a dependencies section like this:

"dependencies": {
  "express": "^5.1.0"
}

The dependencies list contains all libraries used in your project.

This file allows you to reinstall all necessary libraries on another computer with just this file.


Creating the First Server File

Create a new file in your project folder with this name:

server.js

We'll write most server code in this file.


Loading Express

First, load Express into your project:

const express = require("express");

Then create an Express application instance:

const app = express();

Your web server is now ready to be configured.


Creating the First Page

We'll display a simple message when users access the homepage:

app.get("/", (req, res) => {
    res.send("Hello! This is my first Express server.");
});

The "\/" represents the homepage URL.

When users request the homepage, the server will respond with this text message.


Running the Server

Add this code to start your server:

app.listen(3000, () => {
    console.log("Server is running.");
});

Port 3000 is commonly used for Node.js development.


Running the Server

In your terminal, enter:

node server.js

If successful, you'll see this message in the terminal:

Server is running.

Verifying in Your Browser

Open Chrome and enter this address:

http://localhost:3000

You should see this message displayed on the screen:

Hello! This is my first Express server.

With this, your first web server is complete.


About localhost

You'll frequently encounter "localhost" when starting development.

Localhost refers to your current computer's special address.

In other words,

http://localhost:3000

refers to the Node.js server running on your local machine, not a server on the internet.

Most testing during development happens using localhost.


About Ports

A port is a number used to run multiple programs simultaneously on one computer.

For example:

  • Port 80: HTTP

  • Port 443: HTTPS

  • Port 3000: Node.js development server

Different programs use different ports.

Understanding ports will be helpful when deploying to servers like Ubuntu later.


What's Next for Our Server?

The server we built today only displays a simple text message.

As the course progresses, this server will gain more features:

  • Serving HTML pages

  • Applying CSS styles

  • Connecting JavaScript

  • Integrating Socket.IO

  • Real-time chat functionality

  • Login systems

  • Database connections

All these features will run on our Express server foundation.

You can think of today's code as the starting point for future projects.


Lesson Summary

In this session, we installed Express and built our first web server.

We also covered package.json's role, how to run a server, and the concepts of localhost and ports.

While simple now, this server will evolve into a full-featured chat application with more advanced features in upcoming lessons.


Next Lesson Preview

In the next lesson, we'll create a chat interface (UI) using HTML and CSS.

We'll build a basic screen where users can send messages and view chat history, laying the foundation for real-time chat functionality.

FAQ

What is a web server?

A web server processes user requests and delivers HTML, CSS, and JavaScript files to browsers.

Why use Express with Node.js?

Express simplifies web server creation with minimal code and provides features like routing and middleware management.

Korean Source

This article is an English localization of a Korean-language report from BlogScore. Original: [Node.JS 강좌] 2강 Node.js와 Express 서버 만들기