Tutorials Build a Real-Time Chat Application with Node.js

Project Setup — Folder, npm & Dependencies

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.

On this page
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

Interview prep for this lesson

Practice these questions aloud after reading—each links to a full structured answer.

Junior Detailed
Describe a real-world scenario where Demo mattered in a Build a Real-Time Chat Application with Node.js project.
Short answer: Interviewers want a crisp definition, a practical example from your projects, and awareness of trade-offs—not textbook dumps. How to structure your answer (60–90 seconds) Define Demo in plain language for B…
Junior Detailed
Explain Design in the context of Build a Real-Time Chat Application with Node.js.
Short answer: Interviewers want a crisp definition, a practical example from your projects, and awareness of trade-offs—not textbook dumps. How to structure your answer (60–90 seconds) Define Design in plain language for…
Mid Detailed
What are common mistakes teams make with Implementation when using Build a Real-Time Chat Application with Node.js?
Short answer: Interviewers want a crisp definition, a practical example from your projects, and awareness of trade-offs—not textbook dumps. How to structure your answer (60–90 seconds) Define Implementation in plain lang…
Senior Detailed
How would you debug a production issue related to Trade-offs in a Build a Real-Time Chat Application with Node.js application?
Short answer: Interviewers want a crisp definition, a practical example from your projects, and awareness of trade-offs—not textbook dumps. How to structure your answer (60–90 seconds) Define Trade-offs in plain language…
Mid Detailed
Compare two approaches to Testing—when would you choose each?
Short answer: Interviewers want a crisp definition, a practical example from your projects, and awareness of trade-offs—not textbook dumps. How to structure your answer (60–90 seconds) Define Testing in plain language fo…
Questions on this lesson 0

Sign in to ask a question or upvote helpful answers.

No questions yet — be the first to ask!

Build a Real-Time Chat Application with Node.js
Course syllabus
Part 1 — Getting Started
Part 2 — Build the App
Part 3 — Run, Learn & Extend
Part 4 — Ship It
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