Now, you should have access to node and npm in your Terminal. You can test them out with the following commands:
$ node -v
V8.9.0
$ npm -v
5.5.1
Note that the output of these commands (for example, v6.2.1 and 3.9.3) can be different, and your environment as the latest version of node and npm can, and most certainly, will be different by the time you read these lines. However, if you at least have these versions, you will be fine for the rest of this book:
$ npm install -g TypeScript
The -g argument stands for global. In the Linux system, depending on your distribution, you might need sudo rights to install global packages.
Very much like node and npm, we can test whether the installation went well with the following:
$ tsc -v
Version 2.6.1
What we have, for now, is the TypeScript transpiler. You can use it like so:
tsc --out myTranspiledFile.js myTypeScriptFile.ts
This command will transpile the content of myTypeScriptFile.ts and create myTranspiledFile.js. Then, you can execute the resultant js file, in the console, using node:
node myTranspiledFile.js
To speed up our development process, we will install ts-node. This node package will transpile TypeScript files into JavaScript and resolve the dependencies between said files:
$ npm install -g ts-node
$ ts-node -v
3.3.0
Create a file named hello.ts and add the following to it:
console.log('Hello World');
Now, we can use our new package:
$ ts-node hello.ts
Hello World