Skip to main content
Angular CLI - ng generate

Angular CLI - ng generate

Generate or modify application files through Angular schematics.

Angular CLI - ng generate illustration

How it works

ng generate (ng g) invokes a schematic such as component, service, guard, or library. Use --dry-run to preview changes, select the correct project in a multi-project workspace, and review generated code before committing it.

Good practice

  • Check the local Angular CLI version and run commands from the intended workspace.
  • Review angular.json targets and builders before assuming optional commands are configured.
  • Use the package manager and lockfile selected by the project.
  • Review generated files, configuration changes, and build output before committing or deploying.

Further reading: Tutorialspoint: Angular CLI - ng generate · Current Angular CLI reference · Workspace configuration.