Installing Typescript on Mac
The most straightforward way to install Typescript on a Mac is using Node.js and npm (Node Package Manager). Upon successful installation of these two resources, Typescript can then be installed via your terminal.
// Installation command for Node.js and npm $ brew install node
Understanding the Code
The command "brew install node" installs both Node.js and npm. Brew is a package manager for Mac, which makes installing and managing packages a breeze. After Node.js and npm are installed successfully, you can proceed to install Typescript.
// Installation command for Typescript $ npm install -g typescript
The "-g" in the code signifies that Typescript is being installed globally on your system. Which means once Typescript is installed, it can be accessed from any directory on your Mac. The "$" before each command symbolizes that the commands should be run in the terminal/command-line.
Libraries and Functions
The fundamental components discussed here are Node.js, npm, Brew, and the Typescript package itself. The Node.js and npm combination fulfills a critical role as it facilitates the installation of other packages like Typescript globally.
- Brew: The missing package manager for macOS (or Linux).
$ tsc helloworld.ts // This is if your Typescript file is named "helloworld.ts"