-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Angular Design Patterns
By :

For the environment setup, I will cover all three major platforms: Debian-flavored Linux, macOS, and Windows. All the tools we are going to use are cross-platform. Consequently, feel free to choose the one you like the most; there is not a thing you will not be able to do later on.
In what follows, we will install Node.js
, npm
, and TypeScript.
$ curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash - $ sudo apt-get install -y Node.js
This command downloads a script, directly into your bash
, that will fetch every resource you need and install it. For most cases, it will work just fine and install Node.js
+ npm
.
Now, this script has one flaw; it will fail if you have Debian repositories that are no longer available. You can either take this opportunity to clean your Debian repositories or edit the script a bit.
$ curl https://deb.nodesource.com/setup_6.x > node.sh $ sudo chmod +x node.sh $ vim node.sh //Comment out all apt-get update //Save the file $ sudo apt-get update $ ./node.sh $ sudo apt-get update $ sudo apt-get install -y Node.js
Then, go to https://Node.js.org/en/download/, and download and install the last .pkg
or .msi
(for Linux or Windows, respectively).
Now, you should have access to node
andnpm
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 -vVersion 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 -v3.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