Skip to main content

Beginner-Friendly Topic

Take your time - it's perfectly normal to re-read this topic 2-3 times. Try the interactive code editor below to run code yourself. Use the Q&A section to check your understanding before moving on.You've got this!

Lesson 2 of 9

Installation & Project Setup

TypeScript is installed as a Node.js package. The TypeScript compiler (`tsc`) converts `.ts` files to `.js`. For development, `ts-node` or `tsx` run TypeScript directly without a separate compile step. Every TypeScript project needs a `tsconfig.json` that controls what the compiler checks and what JavaScript it emits.

12 minBy Priygop Editorial TeamUpdated 2026Peer Reviewed & Verified

Project Setup - From Scratch

Project Setup - From Scratch
# ── Install TypeScript ────────────────────────────────────────
npm init -y
npm install --save-dev typescript @types/node

# ── Generate tsconfig.json ─────────────────────────────────────
npx tsc --init

# ── Install ts-node for development (run .ts directly) ─────────
npm install --save-dev ts-node tsx

# ── package.json scripts ───────────────────────────────────────
# {
#   "scripts": {
#     "dev":   "tsx watch src/index.ts",
#     "build": "tsc",
#     "start": "node dist/index.js",
#     "check": "tsc --noEmit"
#   }
# }

// ── src/index.ts - first TypeScript file ───────────────────────
const message: string = "Hello, TypeScript!";
console.log(message);

// ── Compile & run ──────────────────────────────────────────────
// npx tsc        → compiles to dist/index.js
// npx tsx src/index.ts  → runs directly (no compile step)

// ── tsconfig.json - recommended starter ───────────────────────
// {
//   "compilerOptions": {
//     "target": "ES2022",          // output JS version
//     "module": "commonjs",        // Node.js module format
//     "lib": ["ES2022"],           // API typings available
//     "strict": true,              // all strict checks ON
//     "outDir": "./dist",          // compiled output directory
//     "rootDir": "./src",          // source root
//     "esModuleInterop": true,     // default import compatibility
//     "skipLibCheck": true         // skip type-checking .d.ts files
//   },
//   "include": ["src/**/*"],
//   "exclude": ["node_modules", "dist"]
// }

Common Mistakes

  • Forgetting `--save-dev` when installing TypeScript - it's a development dependency, never a runtime dependency.
  • Running `tsc` without a tsconfig - without config, tsc uses defaults that differ from your project's needs.
  • Using `ts-node` in production - only use it in development. Always compile with `tsc` for production and run the output `.js` files.

Tip

Tip

Practice Installation Project Setup in small, isolated examples before integrating into larger projects. Breaking concepts into small experiments builds genuine understanding faster than reading alone.

Diagram
Loading diagram…

Visual architecture and concepts for Installation & Project Setup

Practice Task

Note

Practice Task - (1) Write a working example of Installation Project Setup from scratch without looking at notes. (2) Modify it to handle an edge case (empty input, null value, or error state). (3) Share your solution in the Priygop community for feedback.

Quick Quiz

Common Mistake

Warning

A common mistake with Installation Project Setup is skipping edge case testing - empty inputs, null values, and unexpected data types. Always validate boundary conditions to write robust, production-ready typescript code.

Key Takeaways

  • TypeScript is installed as a Node.
  • Forgetting `--save-dev` when installing TypeScript - it's a development dependency, never a runtime dependency.
  • Running `tsc` without a tsconfig - without config, tsc uses defaults that differ from your project's needs.
  • Using `ts-node` in production - only use it in development. Always compile with `tsc` for production and run the output `.js` files.

Hands-on Practice Tools for this Course

Test what you learn using these free in-browser developer utilities (no signup required).

All 40+ Tools

Topics in This Module

0/9 done