Master Node.js From Scratch

Clear, interactive, and structured Node.js lessons designed for beginners and developers.

COURSE SYLLABUS
1. Introduction to Node.js
Introduction to Node.js What Is Node.js? Node.js Architecture Features of Node.js Node.js vs Browser JavaScript Node.js Use Cases
2. Installation and Setup
Installation Introduction LTS and Current Versions npm Setup Environment Setup Verify Installation Node.js REPL
3. Node.js Fundamentals
Fundamentals Introduction Running JavaScript Global Objects Process Object Command-Line Arguments Environment Variables
4. JavaScript Basics
JavaScript Basics Introduction Variables: var, let and const JavaScript Data Types Comparison and Logical Operators If, Else If, Else and Switch Loops and Iteration Functions and Arrow Functions JavaScript Array Methods
5. Node.js Modules
Modules Introduction CommonJS Modules ES Modules Export and Import Built-in Modules Creating Custom Modules Path Module OS Module
6. Working with JSON
JSON Introduction JSON Syntax JSON.stringify() JSON.parse() JSON Array of Objects JSON User Database
7. Node Package Manager
npm Introduction package.json Installing Packages Dependencies and DevDependencies npm Scripts Package Versions and Semantic Versioning npm init and Project Setup
8. File System
File System Introduction Reading Files Writing Files Appending Files Deleting Files Working with Directories
9. CLI Applications
CLI Applications Introduction Command-Line Input Task Manager Project Structure Reading todos.json Adding, Updating and Deleting Tasks Saving Tasks to JSON
10. Events and EventEmitter
Events Introduction EventEmitter Registering Events Emitting Events Removing Event Listeners Custom Events
11. Asynchronous Programming
Async Programming Introduction Callbacks Promises async and await setTimeout() and setInterval() Event Loop and Non-Blocking I/O
12. Native HTTP Module
HTTP Module Introduction Creating an HTTP Server Handling Requests Sending Responses HTTP Request Methods Status Codes and Headers Handling POST Request Body Parsing Incoming JSON Products JSON API
13. Express.js
Express.js Introduction Installing Express Creating an Express Server Request and Response Objects Route Parameters and Query Strings Serving Static Files
14. Express Middleware
Middleware Introduction Built-in Middleware Application-Level Middleware Router-Level Middleware Custom Middleware Error-Handling Middleware
15. REST API Development
REST API Introduction GET Endpoints POST Endpoints PUT and PATCH Endpoints DELETE Endpoints Request Validation and API Responses
16. Database Integration
Database Introduction MySQL Integration MongoDB Integration Database CRUD Operations Database Queries and Filtering Connection Management
17. Authentication and Authorization
Authentication Introduction Password Hashing User Registration User Login JWT Authentication Authorization and Protected Routes
18. Advanced Node.js
Advanced Node.js Introduction Error Handling Debugging Node.js Applications Streams Buffers Performance and Security

Node.js Installation

Before developing backend applications, we need to install Node.js and npm on our computer.

In this lesson, we will learn how to download Node.js, install it on Windows, verify the installation, and run our first JavaScript program from the terminal.

1. Prerequisites

Before starting the installation, make sure you have:

  • A Windows, Linux, or macOS computer.
  • An internet connection to download Node.js.
  • Permission to install software on your computer.
  • A terminal such as Command Prompt or PowerShell on Windows.
For this tutorial: We will demonstrate the installation steps using Windows and Command Prompt.

2. What Are Node.js and npm?

Node.js is a runtime environment that lets us execute JavaScript outside a web browser.

npm is the package manager commonly used with Node.js. It helps install packages, manage project dependencies, and run scripts.

Tool Purpose Verification Command
Node.js Executes JavaScript programs. node --version
npm Manages packages and project scripts. npm --version

3. Download Node.js

Download Node.js from its official website. For most learners, the LTS release is a good starting point.

Official Node.js Website

Open the official download page and select a version appropriate for your operating system.

Download Node.js

Download Steps

  1. Open the official Node.js download page.
  2. Choose the LTS release unless your project requires another version.
  3. Select the appropriate installer for your operating system.
  4. Download the installer and wait for the download to finish.
Security tip: Download Node.js from the official website or a trusted version manager. Avoid unknown installer websites.

4. LTS vs Current Version

Node.js releases are commonly presented as LTS and Current. The right choice depends on the project's requirements.

LTS Current
Long Term Support. Newer feature releases.
Usually preferred for learning and many production projects. Useful when a project needs newer features.
Receives maintenance and security updates during its support period. May have a shorter support period than an LTS release.

Always check the current official release information and your project's supported Node.js versions before installing.

5. Install Node.js on Windows

After downloading the Windows installer, follow these steps.

  1. Open the installer.

    Double-click the downloaded Node.js installer.

  2. Accept the licence agreement.

    Read the licence and accept it if you agree.

  3. Choose the installation location.

    The default installation location is usually suitable for a learner's computer.

  4. Keep the required features selected.

    Make sure the Node.js runtime and npm package manager are included. Keep the option to add Node.js to PATH enabled.

  5. Complete the installation.

    Click Install and wait for the setup to finish.

  6. Open a new terminal.

    Close and reopen Command Prompt or PowerShell so that the updated PATH is picked up.

6. Installation Flow Diagram

Step 1: Open nodejs.org
↓
Step 2: Download the installer
↓
Step 3: Install Node.js and npm
↓
Step 4: Open a new terminal
↓
Step 5: Verify Node.js and npm

7. Verify the Node.js Installation

After installation, we need to confirm that Node.js is installed and accessible from the terminal.

Step 1: Open Command Prompt

Press Windows + R, type cmd, and press Enter.

Step 2: Check the Node.js Version

Command Prompt
node --version

Example Output

Output — example only
v22.x.x

The exact version will depend on the release installed on your computer. The example above is only illustrative.

Step 3: Check the npm Version

Command Prompt
npm --version

Example Output

Output — example only
10.x.x

If both commands display version numbers, Node.js and npm are accessible from the current terminal.

8. Run Your First Node.js Program

Now that Node.js is installed, let's create and execute a simple JavaScript file.

Step 1: Create a Folder

Create a folder named NodeJsPractice and open that folder in your terminal.

Step 2: Create app.js

Create a file named app.js and add the following code.

JavaScript — app.js
console.log("Node.js installed successfully");
console.log("Welcome to CIIT TRAINING INSTITUTE");

Step 3: Run the File

Terminal
node app.js

Expected Output

Output
Node.js installed successfully
Welcome to CIIT TRAINING INSTITUTE

Program Explanation

  • console.log() displays a message in the terminal.
  • app.js is the JavaScript source file.
  • node app.js asks Node.js to execute that file.

9. Check the Installation Path

The PATH environment variable helps the terminal locate executable commands without requiring their full paths.

Windows Command

Command Prompt
where node
where npm

Example Output

Output — example only
C:\Program Files\nodejs\node.exe
C:\Program Files\nodejs\npm

Your installation location may be different. These commands help identify which executable the terminal is using.

10. Common Installation Problems

Problem Possible Reason Solution
node is not recognized Node.js is missing or not available in PATH. Verify installation, check PATH, and open a new terminal.
npm is not recognized npm is missing or its location is not available in PATH. Check the installation and run where npm.
Old version displayed Another Node.js installation may be found first in PATH. Run where node and check the installation paths.
Permission error The selected folder or operation requires additional permissions. Check folder permissions and use an appropriate installation location.
Port already in use Another application is listening on that port. Stop the other application or select an available port.

Important Points

  • Download Node.js from the official website.
  • Choose a supported version that matches your project requirements.
  • Verify the installation using node --version.
  • Verify npm using npm --version.
  • Use node app.js to run a JavaScript file.
  • Check PATH if the terminal cannot find Node.js or npm.

Practical Learning at CIIT TRAINING INSTITUTE

Correct installation is the first step toward building Node.js applications. Students can practise these setup steps before moving on to JavaScript fundamentals, modules, APIs, and database integration.

Skills Covered in This Lesson
  • Download and install Node.js.
  • Understand the role of npm.
  • Verify versions from the terminal.
  • Create and execute a JavaScript file.
  • Identify common installation and PATH problems.

Summary

Node.js installation provides the runtime required to execute JavaScript programs outside the browser. npm helps manage project packages and scripts. After installing Node.js, verify it using the version commands, check PATH when needed, and run a simple app.js file. These steps prepare students at CIIT TRAINING INSTITUTE for the next stages of backend development.