⚠️ Important Requirement: Node.js Needed
TypeScript requires Node.js to run. If Node.js is not installed:
- 📺 Watch YouTube tutorial: Install Node.js
- 🌐 Follow web guide: Node.js Installation Tutorial
📘 What You Will Learn
This tutorial includes checking Node.js, installing TypeScript, ts-node, generating tsconfig.json, writing hello.ts, compiling & running TypeScript programs.
🎥 Video Tutorial
Step 0 — Check Node.js & npm
TypeScript needs Node to work.
node -v
npm -v
Step 1 — Install TypeScript
Install TypeScript globally:
npm install -g typescript
Verify installation:
tsc -v
Step 2 — Install ts-node
This allows you to run TypeScript directly (without manual compilation).
npm install -g ts-node
Check version:
ts-node -v
Step 3 — Create a Project Folder
Create a folder anywhere (Desktop recommended):
- Right-click → New Folder → newproject
- Open the folder in VS Code
Step 4 — Initialize TypeScript
This creates the tsconfig.json configuration file:
tsc --init
Step 5 — Create hello.ts
Write your first TypeScript program:
const message: string = "Hello manthan"; console.log(message);
Step 6 — Run TypeScript Code
Method 1 — Using ts-node (recommended)
ts-node hello.ts
Method 2 — Compile + Run (without ts-node)
Compile:
tsc hello.ts
Run:
node hello.js
Step 7 — Understanding tsconfig.json
This file controls TypeScript behavior:
- target → Output JS version
- module → CommonJS / ES modules
- rootDir → Source folder
- outDir → Compiled folder
- strict → Enables strict type checking