By Gary simon - Oct 20, 2016
In the previous two articles, I showed you how to manually install an angular 2 project, as well as installing one based on cloning the quickstart repository.
In this article, I will show you the fastest method of launching an Angular 2 project, and that's through what's known as the Angular-cli.
First, if you prefer watching a video tutorial on how to do this, watch here:
Put simply, it's a command line interface for Angular. It allows you:
In a nutshell, it's a workhorse that cuts out a lot of the tedious work involved with Angular development. So let's get started on how to install angular2 with the angular-cli.
Fortunately, this is a step you only have to do once. Once it's installed globally with "-g", you can skip this step when creating new Angular 2 projects. Also it's important to note, you need Nodejs and NPM installed before you can proceed with this step.
Assuming they are, in the command line type: (it doesn't matter which folder you're in for this step).
npm install -g angular-cli
Note: This will take some time, so be patient.
Now, in the command line, navigate to your projects folder and type:
ng new project-title
cd project-title
ng serve
And that's it. The "ng new" command will retrieve all of the files, as well as run the "npm install" command for you. Then you simply cd into the directory, and to run it in the browser (similar to "npm start") you run the "ng serve" command.
It's as simple as that!