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

Verify Node.js Installation

Learn how to verify the Node.js runtime, check npm, execute JavaScript code, inspect environment configuration, and troubleshoot common installation problems.

1. Introduction to Installation Verification

After installing Node.js, we should verify that the installation works correctly. Installation verification means checking whether the Node.js runtime and npm commands are available and functioning as expected.

Sometimes a program may be installed on a computer but may not be accessible from the terminal because of a PATH configuration problem. Verification helps us identify these problems before starting application development.

Important Concept: Successful installation means more than having Node.js files on the computer. We should also confirm that the terminal can execute Node.js and npm commands.

What Should We Verify?

Component Verification Purpose
Node.js node --version Checks the installed runtime version.
npm npm --version Checks npm command availability.
Executable Path where node Checks where Windows finds Node.js.
JavaScript Execution node app.js Confirms that Node.js can execute a file.

2. Node.js Installation Verification Workflow

Follow the verification process in sequence. If one step fails, resolve the issue before moving to the next step.

Step 1: Open Terminal
↓
Step 2: Check Node.js Version
↓
Step 3: Check npm Version
↓
Step 4: Verify Executable Path
↓
Step 5: Execute a JavaScript File
↓
Installation Verification Completed

3. Check the Node.js Version

The first step is to verify whether the Node.js command is available in the terminal.

Step 1: Open Command Prompt or Terminal

Open Command Prompt, PowerShell, or your code editor's integrated terminal.

Step 2: Execute the Command

Terminal
node --version

Explanation

  • node invokes the Node.js executable.
  • --version requests the installed version.
  • The command does not execute a project file.

Expected Output

v22.x.x

The version shown above is an example. Your computer may display a different version depending on your installation.

Successful Result: If a Node.js version appears, the terminal can find and execute the Node.js command.

4. Check the npm Version

npm is the package manager commonly used with Node.js. It helps us install packages, maintain dependency information, and run commands defined in a project's configuration.

Step 1: Execute the npm Version Command

Terminal
npm --version

Expected Output

10.x.x

This is illustrative output. The actual npm version may be different on your computer.

What Does This Confirm?

  • The terminal can locate the npm command.
  • npm can start and report its version.
  • You can proceed to test basic project commands.
Important: Node.js and npm use separate version numbers. Different numbers do not indicate an installation problem by themselves.

5. Verify the Node.js Executable Path

The PATH environment variable helps the operating system find executable commands. Checking the executable path can help troubleshoot installation problems.

Step 1: Find the Node.js Executable

Windows Command Prompt
where node

Example Output

C:\Program Files\nodejs\node.exe

This is an example path. Your installation may use a different location.

Step 2: Find the npm Command

Windows Command Prompt
where npm

Windows displays the locations it can find for the npm command. If multiple locations appear, check that your environment is using the intended Node.js installation.

Note: The where command is intended for Windows Command Prompt. Other terminals and operating systems may use different commands to inspect executable locations.

6. Test JavaScript Execution

Checking the version confirms that the command runs. The next step is to execute an actual JavaScript file.

Step 1: Create a Test File

Create a file named verify.js in a project folder. Add the following code:

verify.js
console.log("Node.js installation verified.");
console.log("JavaScript execution is working.");

const result = 10 + 20;

console.log("Result:", result);

Step 2: Execute the File

Terminal
node verify.js

Expected Output

Node.js installation verified.
JavaScript execution is working.
Result: 30

Code Explanation

Statement Explanation
console.log() Displays a message in the terminal.
const result = 10 + 20; Adds two numbers and stores the result.
console.log("Result:", result); Displays the label and calculated value.
Result: If all three output lines appear correctly, Node.js is executing this JavaScript file successfully.

7. Installation Troubleshooting Flow

If a verification command fails, use this flow to identify the next troubleshooting step.

Run node --version
↓
Does the command display a version?
Yes

Run npm --version and then execute a JavaScript test file.

No

Check the Node.js installation, terminal session, and PATH configuration.

↓
Run the test file using node verify.js
↓
Confirm that the expected output appears

8. Common Verification Errors

Error Possible Reason Solution
Node.js is not recognized Node.js is missing or PATH is not configured. Verify the installation and PATH, then reopen the terminal.
npm is not recognized npm is not available in the current environment. Check the installation and run npm --version again.
Cannot find verify.js The terminal is in the wrong folder or the file is missing. Check the filename and current directory.
Syntax error The JavaScript code contains invalid syntax. Check quotation marks, brackets, and spelling.
Unexpected output The file may contain different code. Save the file and execute it again.
Debugging Tip: Do not immediately reinstall Node.js when a command fails. First inspect the error message, verify the current directory, and check whether the executable is available through PATH.

9. CIIT Training Institute - Practice Task

Task: Verify Your Node.js Environment

  1. Open a terminal.
  2. Run node --version.
  3. Run npm --version.
  4. Check the executable location using where node on Windows.
  5. Create a file named testEnvironment.js.
  6. Print a welcome message using console.log().
  7. Calculate the sum of two numbers.
  8. Execute the file using Node.js.
  9. Compare the terminal output with your expected result.
Expected Result
Welcome to CIIT Training Institute!
Node.js verification completed.
Sum: 50

Your output should match the messages in the example if you use the corresponding statements in your JavaScript file.

Summary

Node.js installation verification confirms that the Node.js runtime and npm commands are working correctly. We checked version numbers, inspected executable paths, and executed a JavaScript file to verify the environment. Understanding PATH configuration and common errors helps developers troubleshoot installation problems. Practical exercises at CIIT TRAINING INSTITUTE help students build a strong foundation for Node.js development.