Skip to content

Sastik/nodejs-backend-basics-tutorial

Repository files navigation

πŸš€ Basic Node.js Tutorial

πŸ’‘ A beginner-friendly repository to learn Node.js fundamentals, core concepts, and backend basics in a simple and structured way.


✨ About Node.js

🟒 Node.js is a JavaScript runtime built on Chrome's V8 engine 🟒 It allows JavaScript to run outside the browser (server-side) 🟒 Used to build fast, scalable network applications


πŸ“œ History

In 2009, Ryan Dahl created Node.js with the idea:

β€œWhy not run JavaScript outside the browser?”

He used the V8 Engine (C++) to execute JavaScript on the server β€” and Node.js was born πŸš€


βš™οΈ V8 Engine

  • JavaScript engine developed by Chrome

  • Converts JavaScript into machine code

  • Other engines:

    • Firefox β†’ SpiderMonkey
    • Edge β†’ Chakra

🎯 Where Node.js is Used

  • ⚑ I/O bound applications
  • πŸ“‘ Real-time chat apps
  • πŸ“Š Data streaming apps
  • 🌐 APIs & backend services

πŸ› οΈ Installation

Step 1:

Download Node.js πŸ‘‰ https://nodejs.org/en/download/

Step 2:

Install it

Step 3:

Verify installation

node -v
npm -v

πŸ“¦ NPM (Node Package Manager)

  • πŸ“š Largest software registry in the world
  • πŸ“₯ Install packages easily
  • βš™οΈ Manage dependencies

Example:

npm install express

🧠 ES6 (Modern JavaScript)

  • Introduced in 2015

  • Adds features like:

    • Arrow functions ➑️
    • let / const
    • Promises
    • Modules

πŸ’» REPL (Read Eval Print Loop)

Node.js provides an interactive shell:

  • R β†’ Read input
  • E β†’ Evaluate
  • P β†’ Print output
  • L β†’ Loop

Features:

  • Run JS expressions
  • Use variables
  • Multiline code
  • _ β†’ last result

🧰 Useful REPL Commands

.help       # Show help
.editor     # Enter editor mode

πŸ“¦ Core Modules

Node.js provides built-in modules:

  • fs β†’ File system
  • http β†’ Web server
  • path β†’ File paths
  • events β†’ Event handling

🌐 Creating a Web Server

Node.js can create its own web server:

const http = require('http');

http.createServer((req, res) => {
  res.write("Hello World");
  res.end();
}).listen(3000);

πŸ“„ JSON

  • Lightweight data format
  • Used for data exchange
  • Common in APIs

πŸ”Œ API (Application Programming Interface)

  • Allows communication between applications

  • Used in:

    • Web apps
    • Mobile apps
    • Services

⚑ Event Module

Node.js is event-driven

const EventEmitter = require('events');
const event = new EventEmitter();

event.on('sayHello', () => {
  console.log('Hello World!');
});

event.emit('sayHello');

🌊 Streams in Node.js

Streams handle data efficiently:

  1. Readable
  2. Writable
  3. Duplex
  4. Transform

πŸ‘‰ Used in real-time processing (video, audio, etc.)


⌨️ Terminal Commands

ctrl + `        # Open terminal
dir             # List files
cd ..           # Go back
mkdir folder    # Create folder
node app.js     # Run file
nodemon app.js  # Auto restart server

🎯 Purpose of This Repo

This project was created to:

  • Learn Node.js fundamentals
  • Understand backend development basics
  • Build a strong foundation for full-stack development

πŸš€ Future Improvements

  • Add Express.js examples
  • Add REST API projects
  • Add MongoDB integration
  • Convert into full backend course

⚑ Note

This repository reflects my early journey into backend development using Node.js.


πŸ™Œ Author

Sastik Kumar Das


⭐ Support

If you find this helpful, give it a ⭐ on GitHub!

About

A beginner-friendly Node.js tutorial repository covering core concepts, modules, REPL, APIs, and server-side fundamentals.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors