How to Install TypeScript on MacOS
Ready to enhance your JavaScript development with TypeScript on your Mac? This guide provides clear instructions on how to install TypeScript on macOS, using either the official installer or the Homebrew package manager. Get started with TypeScript and improve your development workflow today.
This guide provides a step-by-step walkthrough of installing TypeScript on your macOS machine.
How to Install TypeScript on macOS
Step 1: Install Node.js
You have two options for installing Node.js:
Option 1: Using the Installer
- Download Node.js: Visit the official Node.js website (https://nodejs.org) and download the latest Long Term Support (LTS) version for macOS.
- Run the Installer: Double-click the downloaded package file and follow the installation wizard.
Option 2: Using Homebrew
- Install Homebrew (if you don’t have it): Open Terminal and run the following command:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- Install Node.js LTS: In Terminal, run:
brew install node@lts
- Add Node.js to PATH (if needed):
- Open your shell configuration file (
.zshrc
or.bashrc
) in a text editor. - Add the following line at the end of the file:
- Open your shell configuration file (
export PATH="/usr/local/opt/node@lts/bin:$PATH"
- Save the file.
- Restart Terminal or run
source ~/.zshrc
(orsource ~/.bashrc
).
Verify Node.js Installation:
- In Terminal, type
node -v
and press Enter. This should display the installed Node.js version.
node -v
Step 2: Install TypeScript
- Open Terminal: If you closed it, open a new Terminal window.
- Install TypeScript Globally: Run the following command:
npm install -g typescript
- Verify TypeScript Installation:
- In Terminal, type
tsc -v
and press Enter to display the installed TypeScript version.
- In Terminal, type
Step 3: (Optional) Update TypeScript
To update to a newer version of TypeScript in the future, run:
npm update -g typescript
That’s it! You’ve successfully installed TypeScript on your macOS machine and are ready to start developing!
Recent Comments