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

What Is Node.js?

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

Understanding Node.js

Normally, JavaScript runs inside a browser such as Chrome. Node.js provides an environment to run JavaScript directly on a computer or server.

This means developers can use JavaScript for both frontend and backend development.

Simple Example: A webpage may use JavaScript to validate a form. Node.js can receive that form's data on a server and process it.

Where Does Node.js Run?

Browser

JavaScript runs inside the browser.

Webpage interactions
Node.js

JavaScript runs outside the browser.

Servers and backend applications

Both can execute JavaScript, but they provide different environments and APIs.

What Can We Do With Node.js?

  • Create web servers.
  • Build REST APIs.
  • Read and write files.
  • Connect applications to databases.
  • Develop chat and other real-time applications.

Practical Example

Samadhan wants to display a message using Node.js. Let's write a simple program.

Step 1: Create a File

Create a JavaScript file named about.js.

Step 2: Write the Program

JavaScript
let name = "Samadhan";
let technology = "Node.js";

console.log("Hello " + name);
console.log("I am learning " + technology);

Step 3: Execute the Program

Terminal
node about.js

Step 4: Output

Output
Hello Samadhan
I am learning Node.js

Program Explanation

  • let name = "Samadhan"; stores a name in a variable.
  • let technology = "Node.js"; stores the technology name.
  • console.log() prints the message in the terminal.
  • node about.js executes the file using Node.js.

How the Program Executes

about.js

JavaScript program

↓
Node.js

Executes the JavaScript statements

↓
Terminal Output

Hello Samadhan

Important Points

  • Node.js is a runtime environment, not a programming language.
  • JavaScript is the programming language used in Node.js.
  • Node.js can run JavaScript without opening a browser.
  • It is widely used for backend applications and APIs.
  • Use the node filename.js command to run a file.

Summary

Node.js lets us execute JavaScript outside the browser. We can use it to build servers, APIs, and backend applications. We created about.js and executed it using the Node.js command.