First things first, let's talk about Node.js and TypeScript versions. Don't worry if your Node.js version is different from someone else's! Node.js versioning has nothing to do with TypeScript's versioning. It generally doesn't matter what specific TypeScript version you're using.

As long as your Node.js version is greater than 8, you're good to go! You can sip your chai and relax.

However, if you're using a Node.js version lower than 8, then it's time to put your chai down and update it. Newer TypeScript features and tools often rely on modern JavaScript features supported by recent Node.js versions.

Installing Node.js on Windows (if you don't have it)

If you don't have Node.js installed, here's how to get it on Windows:

  1. Visit the Official Node.js Website: Go to https://nodejs.org.
  2. Download the Windows Installer: On the homepage, you'll see options to download the recommended installer for Windows. Choose the LTS (Long Term Support) version, as it's more stable.
  3. Run the Installer: Once downloaded, run the .msi installer file and follow the on-screen prompts. It's usually just a matter of clicking "Next" a few times. This will also install npm (Node Package Manager).

After installing Node.js, our second step is to set up TypeScript on your machine!

Prerequisites

You should now have Node.js and npm (Node Package Manager) installed on your system.

Step 1: Initialize a New Project

First, create a new directory for your project and navigate into it. Then, initialize a new npm project. This will create a package.json file to manage your project's dependencies.

mkdir my-typescript-project
cd my-typescript-project
npm init -y

The -y flag answers "yes" to all the setup prompts, giving you a default package.json file.

Step 2: Install TypeScript (Globally or Locally)

You have two main options for installing TypeScript:

A) Locally (Recommended for Projects)

Installing TypeScript locally (as a development dependency) is the preferred method for most projects. This ensures that everyone working on the project uses the exact same TypeScript version, leading to reproducible builds.

npm install --save-dev typescript