This week we'll begin creating our Angular 2 applications using the Angular CLI tool. CLI stands for "Command Line Interface" and refers to a tool that can be used directly from the command line.
Angular CLI will allow to create entire projects with basic boilerplate code already in place. It will also allow us to generate new portions of projects, like components, services, and pipes directly through the command line.
This lesson will walk through the process of installing Angular CLI and a known issue you may encounter. Let's get started!
Angular CLI tool can be installed with npm. It requires Node 4 or higher and npm 3 or higher.
You were already prompted to install at the beginning of this course. You can confirm your versions are correct by following the instructions available in the Installing Node.js lesson from this course's pre-work. Or, you may visit this lesson to install Node at this time, if you haven't already.
As depicted on the Angular CLI homepage we can install the package with one simple command:
$ npm install -g @angular/[email protected]
You may receive an error that looks like this:
$ npm install -g @angular/[email protected] npm ERR! cb() never called!
At the time of this writing, this appears to be a known issue with npm. As mentioned in the issue discussion, updating node should resolve the error.
On a Mac, you should be able to upgrade node through Homebrew using the following command:
$ brew upgrade node
On a Windows or Linux machine (or a Mac that doesn't use Homebrew), you can simply return to the Node.js Download Page and select the latest version for your particular operating system. Running this installer should override your current (older) version of Node.
In addition to the angular-cli package itself, we'll also require typings and typescript just like last week.
You can confirm your typescript package is installed and ready to go by running:
$ npm list -g typescript
You should receive a version number in response, like this:
Any version number should be fine, but if you do not receive a version number, install the package with the following command:
$ npm install -g typescript
Great! Now that we have the necessary tools, we'll create a new project using Angular CLI and discuss the additional setup needed to configure tools like Bower that we'll continue using throughout our second week of Angular.