Create your account

Already have an account? Login here

Note: By joining, you will receive periodic emails from Coursetro. You can unsubscribe from these emails.

Create account

How to Install Angular 2 with the Angular-cli

By Gary simon - Oct 20, 2016

Ready to build Awesome Angular Apps?

A Free Course, Free Tutorials and Full App Development Courses!

Great! Check your email

I've just sent you the first email to get you started.

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:

What is the Angular-cli?

Put simply, it's a command line interface for Angular. It allows you:

  • Quickly generate a new Angular 2 project.
  • Generate routes, components, services and pipes.
  • Serve your application.
  • Test your application.

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.

 

Step 1: Install 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.

 

Step 2: Start your angular project

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!


Share this post




Say something about this awesome post!