Angular CLI useful commands
Angular CLI Commands
List of useful CLI commands:
ng add — It add up to the development project an outside reference library and utilize the package manager to copy new dependencies and initiate a script used for installing. We can easily add a dependency which may be breaking our application with this command.
ng build — Compiles the application into a “dist” folder at a specific route for yield. Generally, we use this command after making changes in the application and before serving our application to check if the build is successful. It is also helpful to make sure that our build does not fail after we push our changes to the repository and before creating a pull request.
ng e2e — Simply put, it is used to run end-to-end tests using Protractor once it builds and run our application. It is generally used to check the end-to-end workflow of our application.
ng test — It is used to run the unit tests using Jasmine and karma. The unit tests can be performed on the components, functions, testing a form with a service or without along with other use cases.
ng generate — It is a very useful to quickly generate a component, directive, pipe, service, module as per our requirement.
Get Harpreet Brar’s stories in your inbox
Join Medium for free to get updates from this writer.
ng help — The straightforward command instructions are stated alongside with concise explanations.
ng lint — It verifies the code superiority of the project. Generally, after development minor linting issues may arise which may be quickly fixed with ng lint — fix command. If the linting issues are not fixed, we may not be able to successfully push our code to the remote repository.
ng new — Creates an Angular application and a new workspace from scrap. If we are using a repo for creating the project in our local, we generally do not use this command.
ng serve — This will register the angular application when the file is saved and reload the browser with the freshly compiled app. So, the changes we make are presented on the browser once this command executes.
ng update — This command updates your app as well as its dependencies. We can also update the cli using command ng update @angular/cli @ <version_number>. This command is very useful when the entire team in a project would like to be on the same CLI version.
ng version — It lists the angular cli version installed on the machine.
ng cache — Angular CLI saves numerous cacheable functions on disk by default. When you re-run the similar build, the develop structure rebuilds the status of the earlier build and re-uses formerly completed processes, which lessens the time taken to build and test the products and collections.
ng deploy — Initiates the deploy planner for the default development project in the workspace.







