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.
-
Which command installs the TypeScript compiler for every folder of the machine?
Answer
npm i -g typescriptnpm installs the package and
-gputs one copy in the global folder that every shell reaches. -
Which command prints the version of the installed compiler?
Answer
tsc --versiontsc --versionprints a line such asVersion 5.9.2, and a version line means the install worked. -
What does
tsc --initcreate in the current folder?Answer
tsconfig.json, the starter compiler configurationThe command writes a commented tsconfig.json whose options the next lessons change.
-
You installed TypeScript with
npm i -g typescript, but a terminal that was open during the install saystsc: 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.
-
What does this program print?
const version: string = "5.9.2"; console.log(version);Answer
5.9.2
console.logprints the string itself, without quotes or a label. -
What does this program print?
const parts = ["tsc", "--version"]; console.log(parts.join(" "));Answer
tsc --version
joinputs the given separator between the items, so the two words get one space. -
What does this program print?
console.log("Node".toLowerCase());Answer
node
toLowerCasereturns the same text in lower case, and the original string is not changed. -
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. -
What does
node --versiontell you after a correct install?Answer
The version of the Node runtime, as a line that starts with
vNode prints its own version, while npm and tsc each print theirs under their own command.
-
Why does the course install TypeScript globally instead of into one project?
Answer
One copy of
tscis reachable from every folder of the machineThe global install puts the
tsccommand on the search path once, so every project folder can call it.
Article author: Arthur Isaev