CLI Commands
Angular CLI is a powerful tool that automates many development tasks. Here are the most commonly used commands.
ng new [project-name] – Creates a new Angular project.
ng serve – Builds and serves the app, watching for changes.
ng generate (or ng g) – Generates components, services, modules, etc.
ng generate component my-component
ng g c my-component # shorthand
ng generate service my-service
ng g s my-service
ng generate module my-module
ng g m my-module
ng generate directive my-directive
ng generate pipe my-pipe
ng build – Builds the app for production (output in dist/ folder).
ng test – Runs unit tests.
ng e2e – Runs end-to-end tests.
ng lint – Lints your code.
ng help – Lists available commands.
Most commands accept options. For example:
ng g c my-component --skip-tests # don't create test file
ng serve --open # automatically open browser
Two Minute Drill
ng new– create project.ng serve– run dev server.ng generate– create components, services, etc.ng build– production build.- Use
--helpfor command details.
Need more clarification?
Drop us an email at career@quipoinfotech.com
