🚀 Node.js Basics & Setup

Interactive Learning Module - Complete Unit 3

Start Learning

Learning Objectives

Understand Node.js

Runtime, V8 engine, backend development.

Installation

Install Node.js, npm, configure PowerShell.

Programming

REPL, JavaScript files, app.js, index.js.

What is Node.js?

Node.js is a JavaScript runtime environment built on Google's V8 JavaScript Engine. It allows JavaScript to run outside the browser and is widely used for backend applications, APIs, command-line tools and real-time applications.

Runtime & V8 Engine

JavaScript

Developer writes code.

Node Runtime

Executes JavaScript outside browsers.

V8 Engine

Compiles JavaScript into machine code.

Output

Console, API or Server.

Event Loop

Node.js uses an event-driven, non-blocking architecture. Long-running I/O tasks are delegated while the event loop continues processing other work.

BlockingNon-Blocking
Waits for file/databaseContinues executing other tasks
Lower concurrencyHigh concurrency

Installation

  1. Download the official MSI installer.
  2. Install Node.js.
  3. Keep "Add to PATH" enabled.
  4. Verify using node -v and npm -v.
  5. Configure PowerShell if required.
node -v
npm -v
Get-ExecutionPolicy
Set-ExecutionPolicy -Scope CurrentUser RemoteSigned

Node.js REPL

> 10+20
30

> function add(a,b){
... return a+b;
... }
> add(5,10)
15

.exit

Executing Scripts

// app.js
console.log("Hello Node.js");

node app.js

Unit Summary