Build a Real-Time Chat Application with Node.js
Lesson 2 of 10 20% of course

Project Setup — Folder, npm & Dependencies

3 · 5 min · 6/7/2026

Learn Project Setup — Folder, npm & Dependencies in our free Build a Real-Time Chat Application with Node.js series. Step-by-step explanations, examples, and interview tips on Toolliyo Academy.

Sign in to track progress and bookmarks.

Project Setup — Folder, npm & Dependencies
Lesson 2 of 10 · Part 1 — Getting Started · Build a Real-Time Chat Application with Node.js
Course: Build a Real-Time Chat Application with Node.js · Lesson: 2/10 · Read time: ~15 min · Level: Beginner

Project Setup — Folder, npm & Dependencies

Every Node.js project starts the same way: create a folder, run npm init, install packages, and organize files. In this lesson we prepare the empty skeleton. No chat logic yet — just a clean foundation.

Step 1 — Create the project folder

Open your terminal (PowerShell on Windows, Terminal on Mac/Linux) and run:

mkdir chat-app
cd chat-app

This creates a folder named chat-app and moves you inside it. All project files will live here.

💡 Tip: Keep the folder name lowercase with a hyphen (chat-app). Avoid spaces — they cause painful paths on some systems.

Step 2 — Initialize npm (package.json)

npm is Node’s package manager. It tracks your dependencies (Express, Socket.IO) and scripts (how to start the app).

npm init -y

The -y flag accepts all defaults instantly. You will see a new file: package.json.

Step 3 — Install production dependencies

We need two packages:

  • express — serves files and handles HTTP
  • socket.io — real-time WebSocket communication
npm install express socket.io

npm downloads packages into node_modules/ and records versions in package.json.

Step 4 — Install dev dependency (nodemon)

During development, nodemon restarts the server automatically when you save a file — no manual stop/start every time.

npm install --save-dev nodemon
⚠️ Common Mistake: Running npm install nodemon without --save-dev puts a development tool in production dependencies. It still works locally, but Railway/production installs unnecessary packages.

Step 5 — Update package.json scripts

Open package.json and make sure the scripts section looks like this:

{
  "name": "chat-app",
  "version": "1.0.0",
  "description": "Real-time chat app with Node.js, Express, and Socket.IO",
  "main": "server.js",
  "scripts": {
    "start": "node server.js",
    "dev": "nodemon server.js"
  },
  "keywords": ["chat", "socket.io", "nodejs", "express"],
  "author": "",
  "license": "MIT",
  "dependencies": {
    "express": "^4.21.0",
    "socket.io": "^4.8.0"
  },
  "devDependencies": {
    "nodemon": "^3.1.0"
  }
}
  • npm run dev — starts server with nodemon (development)
  • npm start — starts server with plain Node (production / Railway)

Step 6 — Create folder structure

Create the public folder for frontend files. We add the actual HTML/CSS/JS in the next lessons.

mkdir public

Your tree should match this:

chat-app/
├── public/
│   ├── index.html      ← Chat UI (login + messages)
│   ├── style.css       ← WhatsApp-style layout & colors
│   └── client.js       ← Socket.IO client logic
├── server.js           ← Express + Socket.IO server
├── package.json        ← Dependencies & npm scripts
└── node_modules/       ← Created after npm install (do not edit)
👨‍🏫 Teaching note: Draw this folder tree on a whiteboard. Beginners often confuse server.js (backend) with files inside public/ (frontend sent to the browser).

Checkpoint — verify before moving on

  • ✅ Folder chat-app exists
  • package.json lists express, socket.io, nodemon
  • node_modules/ folder exists after install
  • ✅ Empty public/ folder exists

In the next lesson we write server.js — the brain of the chat app.

Continue learning

Previous: Introduction — What We Are Building

Next: Building the Server — Express & Socket.IO

Course home: All 10 lessons

Test your knowledge

Quizzes linked to this course—pass to earn certificates.

Browse all quizzes
Build a Real-Time Chat Application with Node.js

On this page

Step 1 — Create the project folder Step 2 — Initialize npm (package.json) Step 3 — Install production dependencies Step 4 — Install dev dependency (nodemon) Step 5 — Update package.json scripts Step 6 — Create folder structure Checkpoint — verify before moving on Continue learning
Part 1 — Getting Started
Introduction — What We Are Building Project Setup — Folder, npm & Dependencies
Part 2 — Build the App
Building the Server — Express & Socket.IO Frontend HTML — Login Screen & Chat Layout Frontend CSS — Modern Chat UI Design Frontend JavaScript — Connect & Send Messages
Part 3 — Run, Learn & Extend
Running the App & Testing in Two Tabs How Socket.IO Works — Deep Dive
Part 4 — Ship It
Bonus Features — Typing, Online Users & Timestamps Deploy to Railway, Troubleshooting & Summary
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details