Install TypeScript

Node first

TypeScript runs on Node, so install Node before anything else. Any recent long term support release works well for this course. Confirm the install with two version checks:

node --version

v24.22.3

npm --version

11.12.1

Both commands print a version number when the setup is correct. When the terminal reports that the command was not found, reinstall Node and open a fresh terminal window.

npm i -g typescript

Install the compiler with one npm command. The g flag installs a single copy for the whole machine, so every folder can reach tsc without a local install:

npm i -g typescript

added 1 package in 2s

The download takes under a minute on a normal connection. When npm finishes, the tsc command becomes available in every new terminal.

tsc --version

Check that the compiler answers. The exact number on your machine may be newer than the one below, and any recent version is fine for this course:

tsc --version

Version 5.9.2

A version line means the install worked. When the terminal still cannot find tsc, close the terminal completely and open it again so the new search paths take effect.

tsc --init

Move into your project folder and generate a starter config. This file stores compiler options so you never type long flag lists by hand:

tsc --init

Created a new tsconfig.json

You can learn more at https://aka.ms/tsconfig

The command creates tsconfig.json in the current folder. The next lesson uses it to compile your first program.

Questions

A new set of questions in a new order every time. Choose one answer for each, then check.

  1. Which command installs the TypeScript compiler for every folder of the machine?

    Answer

    npm i -g typescript

    npm installs the package and -g puts one copy in the global folder that every shell reaches.

  2. Which command prints the version of the installed compiler?

    Answer

    tsc --version

    tsc --version prints a line such as Version 5.9.2, and a version line means the install worked.

  3. What does tsc --init create in the current folder?

    Answer

    tsconfig.json, the starter compiler configuration

    The command writes a commented tsconfig.json whose options the next lessons change.

  4. You installed TypeScript with npm i -g typescript, but a terminal that was open during the install says tsc: command not found. What is the first thing to try?

    Answer

    Open a new terminal so it reads the updated search path

    The terminal keeps the search path it started with, and a new window picks up the folder npm installed into.

  5. What does this program print? const version: string = "5.9.2"; console.log(version);

    Answer

    5.9.2

    console.log prints the string itself, without quotes or a label.

  6. What does this program print? const parts = ["tsc", "--version"]; console.log(parts.join(" "));

    Answer

    tsc --version

    join puts the given separator between the items, so the two words get one space.

  7. What does this program print? console.log("Node".toLowerCase());

    Answer

    node

    toLowerCase returns the same text in lower case, and the original string is not changed.

  8. What does this program print? const tool = "npm"; console.log(tool + " i -g typescript");

    Answer

    npm i -g typescript

    + joins two strings into one, so the printed line is the whole install command.

  9. What does node --version tell you after a correct install?

    Answer

    The version of the Node runtime, as a line that starts with v

    Node prints its own version, while npm and tsc each print theirs under their own command.

  10. Why does the course install TypeScript globally instead of into one project?

    Answer

    One copy of tsc is reachable from every folder of the machine

    The global install puts the tsc command on the search path once, so every project folder can call it.

Article author: Arthur Isaev