Angular CLI (Command Line Interface)
Table of contents
Angular is a JavaScript framework for building web applications and Angular CLI (Command Line Interface) is a tool that helps to create, manage, and test Angular projects. Here are some commonly used Angular CLI commands:
ng new [project-name]
Creates a new Angular project with the given name.
ng new my-project
ng serve
Runs the project locally in development mode and starts a development server. It also watches for file changes and automatically rebuilds the application.
ng serve
ng generate [schematic] [name]
Generates new files and updates existing files based on a schematic. The schematic can be a component, service, module, etc.
ng generate component my-component
ng build
Builds the project for production and creates a distribution version in the dist folder. It also minifies and optimizes the code for better performance.
ng build --prod
ng test
Runs unit tests for the project using the Karma test runner.
ng test
ng lint
Lints the project’s code using the configured linter. It checks for code style and potential errors.
ng lint
ng e2e
Runs end-to-end (E2E) tests for the project using the Protractor test framework.
ng e2e
ng update
Updates the project’s dependencies and configuration to the latest version of Angular.
ng update @angular/cli
ng xi18n
Extracts i18n messages from the project’s code for localization.
ng xi18n --output-path src/locale
ng add [package]
Add new capabilities to your project with additional libraries or packages.
ng add @ng-bootstrap/schematics
ng deploy
Deploys the application to a specified platform.
ng deploy --project my-project
ng doc [keyword]
Opens the official Angular documentation in the browser and searches for the specified keyword.
ng doc component
ng eject
Ejects the project from the Angular CLI and gives you full control over the build and configuration.
ng eject
` ng help`
Displays a list of available commands and their descriptions.
ng help
ng version
Shows the version of the installed Angular CLI and the version of the locally installed packages.
ng version