How to Install TypeScript on Linux (npm, apt and dnf Guide)

typescript logo

Use this guide if you need a Linux-specific TypeScript install path. If you want the family overview first, start with How to Install TypeScript on Windows, macOS and Linux. For the sibling platform guides, see Windows and macOS.

Quick Answer

  1. Install Node.js (which includes npm): sudo apt install nodejs npm -y
  2. Install TypeScript globally: sudo npm install -g typescript
  3. Verify the installation: tsc --version
  4. Compile a TypeScript file: tsc yourfile.ts

Before You Start

TypeScript is distributed through npm, so Linux systems need Node.js first. On most distributions, the fastest route is to install Node.js and npm from the native package manager, then install TypeScript globally or per project.

Install Node.js on Debian and Ubuntu

sudo apt update
sudo apt install -y nodejs npm
node -v
npm -v

Install Node.js on Fedora, RHEL, Rocky Linux and AlmaLinux

sudo dnf install -y nodejs npm
node -v
npm -v

Install Node.js on Other Linux Distributions

Use your platform package manager if you are on Arch Linux, openSUSE, or another distribution. For example:

sudo pacman -S nodejs npm

Install TypeScript Globally

Once Node.js and npm are installed, add the TypeScript compiler globally:

npm install -g typescript
tsc -v

This gives you the tsc command system-wide.

Install TypeScript Per Project

If you want a project-local compiler version, initialize a project directory and install TypeScript as a development dependency:

mkdir my-typescript-project
cd my-typescript-project
npm init -y
npm install --save-dev typescript
npx tsc --init

Compile a Test File

Create a quick file and verify the compiler works as expected:

echo 'const message: string = "TurboGeek";' > hello.ts
tsc hello.ts
ls

You should now see hello.js alongside the TypeScript file.

Troubleshooting on Linux

  • Old Node.js packages: some long-term-support distributions ship older Node.js versions. If you need a newer compiler toolchain, consider the NodeSource repository or a version manager such as nvm.
  • tsc not found: confirm the global npm binary path is in your shell PATH or run npx tsc inside a project.
  • Permission issues: avoid using sudo npm install -g unless you understand the ownership impact. A version manager is often cleaner for dev workstations.

Related TypeScript Guides

After TypeScript is installed on Linux, the next improvement is usually creating a tsconfig.json, choosing a package manager workflow, and integrating compilation into your build or CI pipeline.

Elsewhere On TurboGeek:  How to Install TypeScript on Windows, macOS and Linux

Want more of this kind of guide?

Use the blog and category routes to keep moving through the archive, or support TurboGeek if the site saves you time regularly.

Translate ยป