0% found this document useful (0 votes)
1 views15 pages

Node Module1 WhatIsNodeSetup

This document outlines a module on Node.js, detailing its importance, setup, and usage in backend development. It covers key topics such as npm, package management, and creating a Node project, while emphasizing the use of JavaScript for both frontend and backend. Additionally, it provides practical exercises and common beginner mistakes to avoid.

Uploaded by

vischiragjain
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)
1 views15 pages

Node Module1 WhatIsNodeSetup

This document outlines a module on Node.js, detailing its importance, setup, and usage in backend development. It covers key topics such as npm, package management, and creating a Node project, while emphasizing the use of JavaScript for both frontend and backend. Additionally, it provides practical exercises and common beginner mistakes to avoid.

Uploaded by

vischiragjain
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

M E R N S TA C K — N O D E .

J S F O U N D AT I O N

Module 1: What is [Link]? + Setup


React se aage — ab JS ko server side chalana seekhte hain,
npm ko poori tarah samajhte hue.

Ycotes Computer Classes | Prepared by Chirag Sir | +91 9216988327


ROADMAP

Is Module Mein Kya Kya Cover Hoga

1 2
[Link] hai kya, aur kyun zaroori hai Install karna + Node se files run karna

3 4
npm — [Link] ki poori anatomy Dependencies, scripts, semantic versioning

5 6
Global vs Local packages, npx Apna pehla Node project banana

Ycotes Computer Classes | Prepared by Chirag Sir | +91 9216988327 2


RECAP

React Course Se Yaad Hai?


• React Module 1 mein humne ek line mein [Link] chhua tha — 'JS ko browser ke bahar chalane wala engine'.
• Ab tak Node sirf ek tool tha jisse hum 'npm run dev' chala rahe the — kabhi khud Node se JS backend code nahi likha.
• MERN mein N = Node — yehi hamara backend banega. Isliye ab isko poori tarah, gehraai se samajhte hain.
• Achi baat: JavaScript wahi hai jo tumhe pehle se aati hai — sirf environment naya hai.

Ycotes Computer Classes | Prepared by Chirag Sir | +91 9216988327 3


DEFINITION

[Link] Hai Kya, Exactly?


[Link] ek JavaScript runtime hai, jo Chrome ke V8 engine par bana hai — isse JS browser
ke bahar, seedha computer/server pe chalti hai.

Same Language, Dono Taraf

Frontend (React) aur Backend (Node) — dono JavaScript. Ek hi language seekh ke poora app bana sakte ho.

Non-Blocking I/O

Node ek waqt mein bahut saare requests handle kar sakta hai bina ek dusre ko roke — servers ke liye perfect.

Bahut Bada Ecosystem

npm pe lakhon ready-made packages hain — har chhoti-badi zaroorat ke liye.

Ycotes Computer Classes | Prepared by Chirag Sir | +91 9216988327 4


REAL WORLD

Kaun Use Karta Hai [Link]?


Bade real-world platforms [Link] pe hi apna backend chalate hain:

Netflix LinkedIn PayPal Uber NASA Walmart

Ek Real Example

Socho tumhari Ycotes Student Portal app hai. Abhi tak data 'fake' tha ([Link] mein hardcoded). Real app mein, jab student form submit karta
hai, ye data kahin 'save' hona chahiye — hamesha ke liye, sabke liye.

Yehi kaam backend ([Link]) + database (MongoDB) karte hain — data ko safely store aur serve karna.

Ycotes Computer Classes | Prepared by Chirag Sir | +91 9216988327 5


SETUP

Install Karo Aur Check Karo


[Link] se LTS (Long Term Support) version install karo — npm khud-ba-khud saath aata hai.

$ node -v // Node ka version dikhayega


$ npm -v // npm ka version dikhayega

Agar dono commands se version number aata hai — install ho chuka hai, ready ho!

Note: React course mein tumne Vite ke through indirectly Node use kiya tha. Ab hum use directly, seedhe, apna backend code likhne ke liye use karenge.

Ycotes Computer Classes | Prepared by Chirag Sir | +91 9216988327 6


HANDS-ON

Node Se JS File Run Karna


Koi HTML, koi browser nahi chahiye — seedha terminal se JS chalti hai.

[Link] Terminal

const name = "Chirag" $ node [Link]


[Link](`Namaste, ${name}!`) Namaste, Chirag!

REPL (Read-Eval-Print-Loop)

$ node // bina file ke, seedha JS type karke test karo


> 2 + 2
4

Ycotes Computer Classes | Prepared by Chirag Sir | +91 9216988327 7


NPM DEEP DIVE

[Link] — Project Ka 'ID Card'


• npm init -y
• [Link] khud-ba-khud bana deta hai (-y = saare defaults accept)
$ npm init -y
• name / version

{ • Project ki pehchaan
"name": "my-app", • scripts
"version": "1.0.0", • Shortcuts — npm start likhne se 'node [Link]' chalega
"main": "[Link]", • dependencies
"scripts": {
• Jo bhi packages install karoge, yahan list ho jayenge
"start": "node [Link]"
},
"dependencies": {}
}

Ycotes Computer Classes | Prepared by Chirag Sir | +91 9216988327 8


NPM DEEP DIVE

Packages Install Karna

$ npm install lodash // normal dependency


$ npm install -D nodemon // sirf development ke liye (-D)
$ npm install // [Link] ki saari deps ek saath

dependencies — App ko chalane ke liye zaroori — jaise express, mongoose

devDependencies — Sirf development mein kaam ki — jaise nodemon (testing/tooling)

node_modules/ — Yahan sab downloaded packages store hote hain — khud kabhi edit mat karo

Ycotes Computer Classes | Prepared by Chirag Sir | +91 9216988327 9


NPM DEEP DIVE

Semantic Versioning — ^, ~, Exact


[Link] mein version numbers ke aage symbols hote hain — ye batate hain kitna 'update' allowed hai.

"express": "4.18.2" Exact — sirf yehi version

"express": "~4.18.2" Patch updates OK — 4.18.x tak

"express": "^4.18.2" Minor + patch updates OK — 4.x.x tak (sabse common)

[Link] — jaise 4.18.2: 4=major (breaking changes), 18=minor (naye features), 2=patch (bug fixes)

Ycotes Computer Classes | Prepared by Chirag Sir | +91 9216988327 10


NPM DEEP DIVE

Global vs Local Packages, Aur npx

Local (-g ke bina) Global (-g ke saath)

Poore computer mein kahin se bhi command jaisa chalta hai (jaise
Sirf isi project ke node_modules mein install hota hai. Zyada tar
nodemon). npx se bina install kiye bhi ek baar ke liye chala sakte
packages (express, mongoose) yahi tarika use karte hain.
ho.

$ npm install express $ npm install -g nodemon


$ npx create-react-app

Ycotes Computer Classes | Prepared by Chirag Sir | +91 9216988327 11


PUT IT TOGETHER

Apna Pehla Node Project Banate Hain

$ mkdir my-first-node-app && cd my-first-node-app


$ npm init -y
$ npm install -D nodemon

// [Link] ke "scripts" mein add karo:


"scripts": {
"dev": "nodemon [Link]"
}

// [Link] banao, kuch likho, phir:


$ npm run dev

// nodemon = file save karte hi Node khud restart


// ho jaata hai — bilkul Vite ke HMR jaisa feel

Ycotes Computer Classes | Prepared by Chirag Sir | +91 9216988327 12


WATCH OUT

Common Beginner Mistakes


node_modules/ ko Git mein commit karna

Fix: .gitignore mein 'node_modules' add karo — ye sirf npm install se wapas ban jaata hai


[Link] bina banaye packages install karna

Fix: hamesha pehle 'npm init -y' karo, phir install karo


Global install pe depend rehna team projects mein

Fix: project-specific packages local hi rakho, taaki sabke system pe same version chale


[Link] ko delete/ignore karna

Fix: ise commit karo — ye exact versions lock karta hai, sabke liye same setup

Ycotes Computer Classes | Prepared by Chirag Sir | +91 9216988327 13


WRAP UP

Quick Recap + Practice Task


• [Link] = JS runtime jo browser ke bahar JS chalata hai (V8 engine par)
• node [Link] se file run, 'node' se REPL 🎯 PRACTICE TASK
• npm init -y se [Link] banta hai
• dependencies vs devDependencies ka farak
1. node -v aur npm -v chalao, versions note karo
• ^, ~ semantic versioning symbols
• nodemon se auto-restart wala dev workflow
2. Ek naya folder banao, npm init -y karo

3. Ek [Link] banao jisme apna naam [Link] ho, node [Link]


se run karo

4. nodemon install karo (dev dependency), 'dev' script banao,


aur try karo

Next Module → Module System (require/import)

Ycotes Computer Classes | Prepared by Chirag Sir | +91 9216988327 14


Shukriya!
Questions? Doubts? Comment ya class mein poocho.
Agle module mein milte hain — Module System ke saath.

YC OT E S C O M P U T E R C L A S S E S

You might also like