This repository contains my learning progress while exploring Node.js. Iβm documenting commands, concepts, and server logic that Iβve worked on step-by-step.
Command | Description |
---|---|
npm --version |
Check the installed version of npm |
npm init |
Initialize a Node.js project (package.json ) |
npm init -y |
Quick init with default values |
npm install slugify or npm i slugify |
Install a single package |
npm i express jsonwebtoken |
Install multiple packages |
npm install --save-dev nodemon |
Install as a dev dependency |
npx nodemon filename.js |
Run with auto-reload (without global install) |
node filename.js |
Run directly with Node.js |
npm install -g nodemon |
Install nodemon globally |
nodemon filename.js |
Run and watch file using global nodemon |
npm run dev |
Run custom script (like dev ) from package.json |
"scripts": {
"start": "node Node.js",
"dev": "nodemon Node.js"
}
Now you can run:
npm run dev
β for development servernpm start
β for production server
npx
allows running binaries from node_modules/.bin/
without installing them globally.
Example: npx nodemon Node.js
looks for nodemon
in local dependencies and executes it.
Use NVM to manage multiple Node.js versions:
nvm install 16
nvm use 16
npm config get prefix
β Shows global npm pathnpm cache clean --force
β Clean npm cache- Set global path: e.g.,
E:\Users\MADHAV\npm
(add to environment variables)
HTTP methods youβll use in APIs:
Method | Purpose |
---|---|
GET |
Retrieve data |
POST |
Send data |
PUT |
Full update |
PATCH |
Partial update |
DELETE |
Delete data |
π HTTP Status Codes β MDN
Serverβs main role is to process data between frontend and database. It does not store data permanently.
Common commands:
node server.js
npm start
npm run dev
Add custom script in package.json:
"scripts": {
"Madhav": "node nodeServer.js"
}
Run it with:
npm run Madhav
Stop the server with:
Ctrl + C
Instead of restarting the server manually after every change:
-
Install it:
npm i nodemon
-
Use it in scripts:
"dev": "nodemon server.js"
-
Run it:
npm run dev
It will auto-restart your server when changes are detected.
You can explore useful packages at https://www.npmjs.com
If you share or clone the project:
- Delete
node_modules/
andpackage-lock.json
(to save space) - Run
npm install
to regenerate them
netstat -ano
β See all available localhost ports
- TCP: Reliable, connection-oriented, slower, continuous handshake.
- UDP: Fast, connection-less, used for chunks, no guarantee of delivery.
I'm currently exploring advanced Node.js server handling like:
- User Sign In / Sign Out
- Handling POST, DELETE, GET in real APIs
- Error handling, routing, and more...
Next: I will learn Express.js and update this repo accordingly. Stay tuned!
β If this helps you or you want to support my learning, drop a star and follow my progress!