Most Useful Angular Commands you must know



This post will explain you about few angular commands which are frequently used in angular development...

1) npm install @angular/cli -g 

Description : Used to install angular cli.

To uninstall use "npm uninstall -g @angular/cli"  To get latest angular/cli use "npm install @angular/cli@latest"

2) ng new project_name 

Description : Used to create project with all angular stuff.

3) ng new project_name --dry-run

Description : The main use of dry-run is to check, what files will be effected/created , if the command excecutes you can observe it in terminal window but files will not be created.

4) npm install 

Description : Used to Install the dependencies in the local node_modules folder.By running this all the modules present in the package.json will be installed.
              Ex: If you clone an angular project from soruces like github or some other repositories make sure to run this command first.    

5) npm install packageName --save

Description : If you install any package using "npm install" try to use the word  "--save" in the command. you can also install the package without using "--save" but that package will not be added in "devDependencies" section in package.json

6) npm new project_name --style scss 

Description : By default angular project comes with css file i.e when we create new component one css file will created.if you don't want css instead of it if you want to use sass(scss) file you need to use the above command.sass files are more preferred than css files.

7) ng g c componentName 

Description : Used to Create Component.

8) ng g cl className

Description : Used to create class 

9) ng g s serviceName

Description : Used to create service.

10) ng g d directiveName

Description : Used to create directive.

11) ng g e enumName

Description : Used to create enum.

12) ng g g guardName

Description : Used to create guard.

13) ng g i interfaceName

Description : Used to create interface.

14) ng g m moduleName

Description : Used to create module.

15) ng g p pipeName

Description : Used to create pipe.

16) ng build 

Description : Used to build the application.

17) ng serve 

Description : Used to run the application
    
18) ng serve --port 4001

Description : By default angular will run on 4200 port you can change it by using above command.But make sure that port is not used by other application.

Labels: angular commands , top commands in angular, component creation command, service creation command, class creation command, module creation command, directive creation command in angular, angular



Subscribe

Receive Quality Tutorials Straight in your Inbox by submitting your Email below:

Delivered by FeedBurner

Protected by Copyscape Duplicate Content Checker