Install TypeScript on Ubuntu

Update apt

TypeScript runs on Node, so install Node first. On Ubuntu begin by refreshing the local package index. Fresh lists prevent missing package errors during install:

sudo apt update

Reading package lists... Done

Wait until the Done line appears. The command prints status lines only and changes nothing on its own, so it is safe to run often.

Install Node and npm

Install both runtime tools in one step. Ubuntu ships them as two packages, so name both on the same line:

sudo apt install nodejs npm

Setting up nodejs...

Confirm the default choice when apt asks for approval. The download takes under a minute on a normal connection.

Verify the install

Check that Node and npm answer with version numbers. Open a new terminal when an old one was open during install:

node -v

v20.11.0

npm -v

10.2.4

Version output means the packages landed correctly. When a command is not found, repeat the install step and check for typing errors in the package names.

Newer versions and TypeScript

Ubuntu long term support often ships an older Node. When you need a newer runtime, use a version manager such as nvm/fnm as plain text tool names, then return here. For this course the default apt build is enough to continue.

Add one global copy of TypeScript with npm and check the compiler version:

npm i -g typescript

added 1 package in 2s

tsc --version

Version 5.4.5

Any recent compiler version works for the lessons. When tsc stays unknown, open a fresh terminal so the new search paths take effect.

Next: Install TypeScript on Rocky Linux

Article author: Arthur Isaev