Skip to content

πŸ› οΈ This repository captures my hands-on practice with Node.js and Express.js. It includes simple API setups, routing, server creation, and middleware usage β€” all essential to mastering backend fundamentals. πŸŒπŸ“¦ Laying the groundwork for building scalable web apps as part of my Full Stack Web Dev journey.

Notifications You must be signed in to change notification settings

Madhav-P-2005/Node.js-and-Express.js

Repository files navigation

πŸš€ Node.js And Express.js - A Complete Guide

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.


πŸ“¦ NPM Basics

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 in package.json

"scripts": {
  "start": "node Node.js",
  "dev": "nodemon Node.js"
}

Now you can run:

  • npm run dev β†’ for development server
  • npm start β†’ for production server

🧠 What is npx?

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.


πŸ” NVM – Node Version Manager

Use NVM to manage multiple Node.js versions:

nvm install 16
nvm use 16

πŸ›  Useful npm Commands

  • npm config get prefix β†’ Shows global npm path
  • npm cache clean --force β†’ Clean npm cache
  • Set global path: e.g., E:\Users\MADHAV\npm (add to environment variables)

🌐 HTTP Methods & Status Codes

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


βš™οΈ Node.js Server Logic (Basic)

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

πŸ”„ Why Use Nodemon?

Instead of restarting the server manually after every change:

  1. Install it:

    npm i nodemon
  2. Use it in scripts:

    "dev": "nodemon server.js"
  3. Run it:

    npm run dev

It will auto-restart your server when changes are detected.


🌐 Explore npm Packages

You can explore useful packages at https://www.npmjs.com


πŸ“ Project Transfer Tip

If you share or clone the project:

  • Delete node_modules/ and package-lock.json (to save space)
  • Run npm install to regenerate them

🧡 Network Tools

  • netstat -ano β†’ See all available localhost ports

🧬 TCP vs UDP (Bonus Note)

  • TCP: Reliable, connection-oriented, slower, continuous handshake.
  • UDP: Fast, connection-less, used for chunks, no guarantee of delivery.

πŸ“š Upcoming Learning

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!

About

πŸ› οΈ This repository captures my hands-on practice with Node.js and Express.js. It includes simple API setups, routing, server creation, and middleware usage β€” all essential to mastering backend fundamentals. πŸŒπŸ“¦ Laying the groundwork for building scalable web apps as part of my Full Stack Web Dev journey.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published