How to install Typescript?

To install TypeScript, you’ll need Node.js and npm (Node Package Manager) installed on your system. If you haven’t already installed them, you can download and install Node.js from the official website. npm comes bundled with Node.js.

Here are the steps to install TypeScript:

Step 1: Install Node.js and npm
  1. Go to Node.js download page and download the installer for your operating system.
  2. Once installed, open a terminal or command prompt and verify the installation by running

node -v

npm -v

These commands should output the version numbers of Node.js and npm respectively.

Step 2: Install TypeScript
  1. Open a terminal or command prompt.
  2. Run the following command to install TypeScript globally:

npm install -g typescript

The -g flag installs TypeScript globally, making it available from any location on your system.

Step 3: Verify the Installation

After the installation is complete, verify it by checking the TypeScript version.


tsc -v

This command should output the version number of the TypeScript compiler (tsc).

Run the code into the typescript file

create the app.ts file and put the code into it.


console.log("Hello World");

Compile the TypeScript file to JavaScript:


tsc app.ts

This command generates an app.js file from your app.ts file.

Run the compiled JavaScript file:


node app.js

now, it will show Hello World