Practical Linux, Windows Server and cloud guides for IT pros.

How to Install TypeScript on macOS: Step-by-Step Guide

Use this guide if you specifically need to install TypeScript on a Mac. If you want the cross-platform overview first, start with How to Install TypeScript on Windows, macOS, and Linux. For other operating systems, see the sibling guides for Windows and Linux.

Filed under

Published

Written by

Last updated

typescript logo

Use this guide if you specifically need to install TypeScript on a Mac. If you want the cross-platform overview first, start with How to Install TypeScript on Windows, macOS, and Linux. For other operating systems, see the sibling guides for Windows and Linux.

Quick Answer

  1. Install Node.js via Homebrew: brew install node
  2. Install TypeScript globally: npm install -g typescript
  3. Verify: tsc --version
  4. Compile a TypeScript file: tsc yourfile.ts

Before You Start

TypeScript is distributed through npm, so the first job on macOS is to install Node.js. Most Mac users should either use Homebrew or the official Node.js installer.

Option 1: Install Node.js with Homebrew

If Homebrew is already installed, this is usually the fastest and cleanest path.

brew update
brew install node
node -v
npm -v

If you do not have Homebrew yet, install it first:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Option 2: Install Node.js with the Official Installer

Download the current LTS release from the official Node.js site, run the macOS package installer, then open a new Terminal window and verify the installation:

node -v
npm -v

Install TypeScript Globally

Once Node.js and npm are available, install the TypeScript compiler globally:

npm install -g typescript
tsc -v

This makes the tsc command available from any Terminal session.

Install TypeScript Per Project

If you want a project-local setup instead of a system-wide install, initialize a project and add TypeScript as a development dependency:

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

This approach is usually better for team projects because the TypeScript version is pinned in package.json.

Verify the Compiler

Create a simple test file and confirm the compiler works:

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

You should now see a compiled JavaScript file next to your TypeScript source file.

Troubleshooting on macOS

  • npm or node not found: close and reopen Terminal, then check your PATH.
  • Apple Silicon PATH issue: if Homebrew is installed under /opt/homebrew, add it to your shell profile.
  • Permission errors: prefer Homebrew or a Node version manager rather than forcing sudo npm install -g.
echo 'export PATH="/opt/homebrew/bin:$PATH"' >> ~/.zprofile
source ~/.zprofile

Related TypeScript Guides

With Node.js and TypeScript installed, you can move on to creating a tsconfig.json, compiling your first project, or integrating TypeScript into an existing JavaScript codebase.

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

Leave a Reply

Your email address will not be published. Required fields are marked *

Find more on the site

Keep reading by topic.

If this post was useful, the fastest way to keep going is to pick the topic you work in most often.

Want another useful post?

Browse the latest posts, or support TurboGeek if the site saves you time regularly.

Translate ยป