How to Install TypeScript on macOS (Homebrew and npm 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.

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 Linux (npm, apt and dnf Guide)

Richard Bailey

Richard Bailey is the founder of TurboGeek and has spent more than a decade working across Windows Server, Linux, virtualization, cloud infrastructure and automation. He writes hands-on technical guides for sysadmins, engineers and IT teams, with a focus on clear instructions, practical troubleshooting and real-world infrastructure work.

You may also like...

Leave a Reply

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

Translate »