Angular Project: Must use Angular CLI commands for everyone

7 Most Useful Commands in Angular Project

In this post, I will give you the 7 most helpful commands to speed up your Angular Project.

I assume you have already installed Angular CLI in your system. If not, please install it first from here and read further.

1. Generate app in the current directory

1
ng new <your_app> --directory ./

In case if you want to specify any path, replace ./ with ./your/path.

2. Skip test files

1
ng new <your_app> --skip-tests

This will not add .spec.ts files into your project. You can even use this when generating components, directive, etc.,

1
ng new <your_app> --minimal

You can use this when you want to keep your app simple. This will only add typescript & html files by skipping .spec.ts and .css|.scss|.sass|etc.,.

4. Run & open your application

1
ng serve -o

This will run your project and open’s automatically at the provided port. By default, it open’s at http://localhost:4200

5. Generate files where you wish

1
ng generate <type> /give/your/path/and/name

Let’s take an example of generating a component:

1
ng generate component my-homepage

This will add a component related files in the app directory. In case, you want it to be added in a subdirectory like app/pages. You can use something like this:

1
ng generate component /page/my-homepage

6. Add supported libraries

1
ng add <library>

With this, you can add supported libraries to your angular project will less manual work. Here is an example:

1
ng add @angular/material

7. Build a deployable directory

1
2
ng build
ng build --prod

Hope you like this post. Please subscribe to get updates on more posts like this.

Tagged under:
#Angular #Front-end
Masoom Ul Haq S
About author
Masoom Ul Haq S

Masoom is a Front-end Developer, a UX Engineer and Freelancer based in Bangalore, India. Like to develop differential and effective User Experiences for digital products using an amalgamation of latest technology and best practises.

comments powered by Disqus
You may also like:
Be the first to know about my upcoming writings.