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 Versions

Node.js releases new versions to introduce features, improve performance, fix bugs, and provide security updates.

In this lesson, we will learn how Node.js version numbers work, understand LTS and Current releases, check the installed version, and learn how to manage multiple Node.js versions for different projects.

1. Learning Objectives

After completing this lesson, you will be able to:

  • Understand the Node.js version numbering system.
  • Differentiate between LTS and Current releases.
  • Check the installed Node.js and npm versions.
  • Understand why projects may require different Node.js versions.
  • Learn the basics of Node.js version managers.

2. What Is a Node.js Version?

A Node.js version identifies a particular release of the Node.js runtime. Each release may include new features, bug fixes, performance improvements, and security updates.

A version number commonly follows the Major.Minor.Patch format. Consider the following illustrative example:

Example Version
22.14.0
Version Part Example Meaning
Major 22 Identifies a major release line and may include significant changes.
Minor 14 Identifies a minor release within the major version.
Patch 0 Identifies a specific patch release.
Note: The version 22.14.0 is used only to explain the numbering format. It is not a recommendation for the latest release. Check the official Node.js website for current release information.

3. Types of Node.js Releases

Node.js releases are commonly described as LTS and Current. Each release line serves different development requirements.

A. LTS (Long-Term Support)

LTS stands for Long-Term Support. These releases receive support for an extended period, including maintenance and security updates during their supported lifecycle.

  • Suitable for many production applications.
  • A good starting choice for most learners.
  • Provides a predictable maintenance period.
  • Helps teams plan upgrades and application maintenance.

B. Current Release

The Current release line provides access to newer Node.js features and improvements. It is useful when developers want to evaluate recent capabilities or when a project specifically requires them.

  • Provides newer features earlier.
  • Useful for experimentation and compatibility testing.
  • May have a shorter support lifecycle than an LTS release.
  • Check the support status before using a release in production.

4. LTS vs Current Version

Choosing the correct release depends on your project's requirements, dependency compatibility, and support needs.

Feature LTS Current
Full Form Long-Term Support Current release line
Main Purpose Long-term maintenance and stability Access to newer features
Typical Usage Production and long-running applications Feature evaluation and development
Support Period Extended support lifecycle Generally shorter than LTS
Beginner Choice Usually a good starting point When required by the project
Before Upgrading Check compatibility and release notes Check compatibility and release notes
Important: LTS and Current describe release lifecycle categories, not fixed version numbers. Their status changes over time. Always check the official release schedule before choosing a version.

5. Node.js Release Lifecycle

Node.js releases follow a lifecycle. Depending on the release line, a version may move through active development, LTS support, maintenance, and eventually end of life.

New Node.js Release

A version becomes available.

↓
Release Support Period

Features, fixes, and maintenance depend on the release line.

↓
Maintenance

Updates are provided during the applicable support period.

↓
End of Life

Plan to move to a supported release.

An end-of-life release no longer receives normal upstream maintenance and security updates. Avoid using unsupported releases for production applications unless a specific, properly managed exception applies.

6. Check the Installed Node.js Version

We can check the installed Node.js version using Command Prompt, PowerShell, or a compatible terminal.

Step 1: Open the Terminal

On Windows, press Windows + R, type cmd, and press Enter. You can also open PowerShell.

Step 2: Execute the Command

Command Prompt
node --version

Example Output

Output — example only
v22.14.0

The displayed version depends on the Node.js release installed on your computer. If a version number appears, the terminal can locate and execute Node.js.

Check the npm Version

Command Prompt
npm --version
Output — example only
10.9.2

npm has its own version number. Its version does not have to match the Node.js version because Node.js and npm use separate versioning.

7. Why Do Projects Need Different Versions?

Different applications may depend on different runtime features or package requirements. A project that works with one Node.js release may require testing or changes before running on another.

Example Scenario

Project Requirement Action
Project A Uses an existing supported Node.js version. Keep the required version until compatibility is verified.
Project B Needs features from a newer release. Check the required version and test the application.
Project C Requires consistent versions across the team. Document and standardize the runtime version.

Before changing a project's Node.js version, review its documentation, package requirements, automated tests, and deployment environment.

8. What Is a Node.js Version Manager?

A Node.js version manager is a tool that helps developers install and switch between multiple Node.js versions. It is useful when different projects require different runtime versions.

Common Version Managers

  • nvm: Commonly used to manage Node.js versions on macOS and Linux.
  • nvm-windows: A separate tool designed for managing Node.js versions on Windows.
Node.js Version Manager

Install and select a runtime version.

↓
Version A

Used by Project A.

Version B

Used by Project B.

These tools have different installation and usage instructions. Choose a version manager appropriate for your operating system.

9. Basic Version Management Commands

If you use nvm on macOS or Linux, the following commands can help you inspect the installed versions and available releases.

Terminal — nvm on macOS/Linux
# Display the active Node.js version
node --version

# List installed Node.js versions
nvm ls

# List remote versions available through nvm
nvm ls-remote

Command Explanation

  • node --version displays the active Node.js runtime version.
  • nvm ls lists the Node.js versions managed by nvm.
  • nvm ls-remote lists remote versions available through nvm.
Note: These are nvm commands for macOS/Linux. Standard Windows Command Prompt does not automatically support them. nvm-windows uses its own commands and instructions.

10. Best Practices for Choosing a Version

  • Prefer a supported LTS release for many production applications.
  • Check project documentation before selecting a version.
  • Review release notes before upgrading Node.js.
  • Test application dependencies after changing versions.
  • Use consistent versions across development and deployment environments.
  • Avoid unsupported releases for production applications.

11. Practical Program: Display Node.js Version

Let us create a JavaScript program that displays the version of the Node.js runtime currently executing the file.

Step 1: Create version.js

JavaScript — version.js
console.log("Node.js Version Information");
console.log("Runtime version:", process.version);

Step 2: Execute the Program

Terminal
node version.js

Expected Output

Output — example only
Node.js Version Information
Runtime version: v22.14.0

Program Explanation

  • console.log() displays information in the terminal.
  • process is a global object available in Node.js.
  • process.version provides the version of the Node.js runtime executing the program.

The displayed version will match the runtime used to execute the program, not necessarily every Node.js version installed on the computer.

Practical Learning at CIIT TRAINING INSTITUTE

Understanding Node.js versions is an important step in backend development. At CIIT TRAINING INSTITUTE, learners can practise runtime commands and version compatibility before moving on to modules, npm packages, Express.js, REST APIs, and database integration.

Skills Covered in This Lesson
  • Understand Node.js version numbering.
  • Compare LTS and Current releases.
  • Check Node.js and npm versions.
  • Understand version managers.
  • Recognize compatibility and upgrade requirements.

Summary

Node.js versions identify specific releases of the runtime. LTS releases provide an extended support lifecycle, while Current releases provide access to newer features. Use node --version to check the active runtime and consider a version manager when working on projects that need different versions. Always check release support and project compatibility before upgrading.