0% found this document useful (0 votes)
2 views9 pages

UNIT3 NodeJS MERN Complete Notes

Uploaded by

akulapranay555
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views9 pages

UNIT3 NodeJS MERN Complete Notes

Uploaded by

akulapranay555
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

WEB TECHNOLOGIES - UNIT III

NODEJS & MERN STACK

This document contains detailed UNIT-III preparation notes including: 2 Marks Important Questions 8 Marks Long
Answers Advantages and Disadvantages Diagrams NodeJS Programs with Examples MERN Stack Concepts
PART - A : 2 MARKS QUESTIONS

1. What is NodeJS?
NodeJS is an open-source runtime environment used to execute JavaScript outside the browser. It supports
asynchronous and event-driven programming.

2. Mention features of NodeJS.


Event-driven architecture, non-blocking I/O, asynchronous programming, scalability, npm support.

3. What is npm?
npm stands for Node Package Manager. It is used to install and manage NodeJS packages.

4. What is REPL?
REPL stands for Read Eval Print Loop. It is an interactive shell for executing NodeJS commands.

5. What are Node Modules?


Modules are reusable blocks of JavaScript code.

6. What is EventEmitter?
EventEmitter is a class used for creating and handling events.

7. What is fs module?
fs module is used for file handling operations.

8. What is HTTP module?


HTTP module is used for creating web servers.

9. What is [Link]?
[Link] is a lightweight framework for building APIs and web applications.

10. What is MERN Stack?


MERN stands for MongoDB, [Link], [Link], and [Link].

11. What is MongoDB?


MongoDB is a NoSQL database that stores data in BSON format.

12. What is dotenv?


dotenv is used to load environment variables from .env file.

13. What is local module?


A local module is a module created by the user inside the application.
14. What is third-party module?
Modules installed using npm are called third-party modules.

15. What is asynchronous programming?


Execution of tasks without blocking other operations.
PART - B : 8 MARKS QUESTIONS

Explain NodeJS and its features.


NodeJS is an open-source and cross-platform runtime environment built on Chrome V8 JavaScript engine. It is mainly
used for server-side application development. Features:
1. Event-driven architecture
2. Non-blocking I/O
3. Fast execution
4. Asynchronous programming
5. npm support
6. Cross-platform compatibility
7. Scalability

Advantages:
• Fast execution
• Good for APIs and real-time apps
• Huge community support

Disadvantages:
• Not suitable for CPU intensive tasks
• Callback complexity

Diagram:
Client → NodeJS Server → Database → Response

Explain REPL in NodeJS.


REPL stands for Read Eval Print Loop. It is an interactive environment provided by NodeJS. Working:
1. Read user input
2. Evaluate command
3. Print output
4. Loop again

Commands:
• .help
• .editor
• .save
• .load

Advantages:
• Quick testing
• Easy debugging
• Interactive execution

Diagram:
User Input → REPL → Execution → Output

Explain Node Modules with examples.


Modules are reusable blocks of JavaScript code. Types:
1. Built-in modules
2. Local modules
3. Third-party modules

Local Module Example:


Explain Events Module in NodeJS.
Events module helps in handling asynchronous events. Important methods:
• on()
• once()
• emit()
• removeListener()

Advantages:
• Efficient asynchronous handling
• Faster execution
• Better scalability

Diagram:
Event Emit → Listener → Callback → Output

Explain HTTP module in NodeJS.


HTTP module is used to create web servers. Important concepts:
• createServer()
• req object
• res object
• Routing

Advantages:
• Easy server creation
• Lightweight
• API support

Diagram:
Client Request → HTTP Server → Response

Explain File Handling in NodeJS.


NodeJS uses fs module for file operations. Operations:
• Reading files
• Writing files
• Appending files
• Deleting files
• Renaming files

Advantages:
• Non-blocking execution
• Easy file handling
• Supports asynchronous methods

Diagram:
Application → fs Module → File System

Explain MERN Stack Architecture.


MERN Stack is a full-stack JavaScript framework. Components:
1. MongoDB
2. [Link]
3. [Link]
4. [Link]

Working:
React handles frontend.
Express and NodeJS manage backend.
MongoDB stores data.

Advantages:
• Full-stack JavaScript
• Scalable applications
• Reusable components

Diagram:
React Frontend → Express API → NodeJS → MongoDB

Explain Serverless Hello World Application.


Serverless applications run without managing physical servers. Components:
• AWS Lambda
• API Gateway
• IAM Roles

Advantages:
• Automatic scaling
• Reduced cost
• Easy deployment

Disadvantages:
• Cold start problem
• Vendor dependency

Diagram:
Client → API Gateway → Lambda Function → Response
IMPORTANT NODEJS PROGRAMS

Hello World Server


const http=require('http');

const server=[Link]((req,res)=>{
[Link]("Hello World");
[Link]();
});

[Link](3000,()=>{
[Link]("Server Running");
});

File Read Program


const fs=require('fs');

[Link]('[Link]','utf8',(err,data)=>{
if(err){
[Link](err);
}
else{
[Link](data);
}
});

File Write Program


const fs=require('fs');

[Link]('[Link]',"Hello World",(err)=>{
if(err){
[Link](err);
}
else{
[Link]("File Written");
}
});

EventEmitter Program
const EventEmitter=require('events');

const event=new EventEmitter();

[Link]('msg',()=>{
[Link]("Event Triggered");
});

[Link]('msg');

Express Server Example


const express=require('express');

const app=express();

[Link]('/',(req,res)=>{
[Link]("Welcome");
});

[Link](3000,()=>{
[Link]("Server Running");
});

OS Module Example
const os=require('os');

[Link]([Link]());
[Link]([Link]());
[Link]([Link]());
UNIT III QUICK REVISION
NodeJS: Runtime environment for JavaScript.

[Link]: Backend framework.

MongoDB: NoSQL database.

[Link]: Frontend library.

MERN Stack: Full-stack JavaScript technology.

Important Commands:
npm init -y
npm install express
node [Link]
nodemon [Link]

You might also like