Angular Commands That Are Frequently Used

In this post, we will look at the most often used commands in an Angular project and explain them. They are quite handy in Angular apps.

  • To obtain the npm version,
npm -v
  • To obtain the node version,
node -v
  • To obtain the Angular version,
ng v
  • To obtain the Jasmine version,
jasmine -v
  • To obtain the Karma version,
karma --version
  • To get Angular CLI, follow these steps,
npm install @angular/cli -g
npm install @angular/cli
  • To install the next version of Angular CLI,
npm install @angular/cli@next
  •  To obtain help in the terminal,
ng help
  • To create a new project in Angular,
ng new project-name
  •  To avoid external dependencies while creating a new project,
ng new project-name --skip-install
  • To run the Angular project,
ng serve (or) npm start (or) ng serve --force
  • Dry Run,
ng new project-name --dry-run
  •  To create a new component in the Angular Project,
ng generate component component-name
ng g c component-name
  • To avoid creating a new folder while creating a new component,
ng generate component component-name --flat
  • To create a build,
ng build
  • To make a build for a particular environment,
ng build --prod
  • To run test cases,
ng test
  • To run the end-to-end test,
ng e2e
  • For Angular Documentation,
ng doc
  • To modify the angular-cli.json configuration file,
ng set
  • To make an Angular directive,
ng generate directive directive-name
ng g d directive-name
  • To create a service in Angular,
ng generate service service-name
ng g s service-name
  • To make a class,
ng generate class class-name
ng g cl class-name
  • To create an interface,
ng generate interface interface-name
ng g i interface-name
  • To make a pipe,
ng generate pipe pipe-name
ng g p pipe-name
  • To make enum,
ng generate enum enum-name
ng g e enum-name
  •  To make a module,
ng generate module module-name
ng g m module-name
  • To generate a module specification file,
ng g m module-name --spec true -d
  • To design a routing module,
ng g m module-name --routing
  •  To create a guard to the route,
ng g guard guard-name
  • To remove node_modules,
rm -rf node_modules
  • To uninstall Angular CLI,
npm uninstall --save-dev @angular/cli
npm uninstall -g angular-cli @angular/cli
  • To install the latest version of Angular CLI,
npm install --save-dev @angular/cli@latest
  • To update Angular CLI,
ng update @angular/cli
ng update @angular/core
  • To clean cache,
npm cache clean
  • To install TypeScript latest version,
npm install -g typescript@latest
  • To install Jasmine/Karma latest version,
npm install -g karma-jasmine@latest
  • To install the TypeScript version,
npm install typescript@version-number
  • To install Jasmine specific version,
npm install -g jasmine@version-number
  • Install the Karma-specific version.
npm install -g karma@version-number

Submit a Comment

Your email address will not be published. Required fields are marked *

Subscribe

Select Categories