Learn TypeScript 3 by Building Web Applications
上QQ阅读APP看书,第一时间看更新

Installing TypeScript

TypeScript is distributed as an npm package, and thus, it can easily be installed using npm.

Here's how to install TypeScript globally:

npm install --global typescript

If all goes well, you should be able to execute the compiler from anywhere:

$ tsc --version
Version 3.1.1

As you can see from the preceding command, we could invoke the compiler without prefixing it by its path.

An alternative to the typescript package is the npx command, which comes along with npm. npx allows you to use commands easily without having to go through the hassle of installing packages globally. Note that npx also works for locally installed packages, but we’ll learn about that later on!

Let's now start using TypeScript!