In this tutorial, we will learn how we can create our first Angular 4 application with a few steps.
Step 1
First, we will install NodeJS. If you have not installed it already do so with the help of the below URL:
https://nodejs.org/en/download/
Step 2
When you have successfully installed the NodeJS, you can see the NodeJS command window. Now, open the node JS command window and install the Angular CLI (Command Line Interface for Angular) with the help of the below command:
npm install -g @angular/cli
or
npm install -g @angular/cli@latestBoth of the above commands will install Angular CLI but the command in which I have added the latest one will install the latest version of Angular CLI.
Angular CLI is the command line interface by which we can easily create the Angular 4 application in minimal time. I will discuss all the benefits in my future tutorials.
Step 3
Now to create the new Angular 4 application go to the required location and execute the below command in the NodeJS command window:

Step 4
Now, go to the application which we have created using the below command:
cd new-ang-app
Step 5
Now, you can run the application with one simple step by executing one of the commands below:
ng serve
or
ng serve –open
When you execute an ng-serve command, Angular will open one default port localhost:4200 for your created application.
ng-serve –open command also opens a browser for running the application with URL: localhost:4200
You can also execute npm start command for running your application. When a user executes npm start command, Angular checks the script in a package.json file as below,
- "scripts": {
- "start": "ng serve"
- }
According to the above, npm start will run which you have defined for the start command of the scripts object so in the above case execute an automatic ng-serve command.
It’s the reason that, when we execute npm start command, the ng-serve command will execute.
As you can see, we have successfully created our first Angular 4 application. You can see that running the application from a localhost:4200 URL and output will show what was added in the app.component.html file.
I will discuss Angular application's whole structure in my next tutorial.
Now, we have a few important commands by which we can create component, directive, service and pipes with the help of Angular CLI. When we execute one of the below commands in the NodeJS command window, we can create the one which is required.

Below, g stands for generate which means you can write ng g component new-test-component or ng generate component new-test-component -- both are the same.
Now, you can see we have created our first Angular application. I will define the structure of the created application in my next tutorial.
Before you can fully understand the structure of the Angular application which we have created, you must know why Angular 3 was skipped by the Google Team. We have Angular version 2 and 4 but where is Angular 3? The reason is given below:
As you can see in the above, only the Angular/router version is mismatched so the team has decided to skip Angular version 3 and come up with the next version which is Angular 4.
I hope you liked this -- please share it if you did. My next tutorial will be about the structure of Angular applications.

Riddhi ValechaPosted Sep 28, 2018, 4:07 AM
Hello sir ... Could you please let me know where did I go wrong here ?
Riddhi ValechaPosted Sep 28, 2018, 1:08 AM
I did not get where we can upload here in your article .. Hence I posted it in my posts...
Riddhi ValechaPosted Sep 28, 2018, 1:07 AM
Hello sir... I have removed - node_modules folder and shared the zip file. URL - https://www.c-sharpcorner.com/Forums/crud-operations-in-vs-code
Riddhi ValechaPosted Sep 26, 2018, 8:30 AM
Hello sir... I would like to share my initial project with you and get more help. After zipping the folder, the zip file size is 84MB. So, the portal is not allowing me to attach it. Do you know how to share the zip file here ? Please guide.
Riddhi ValechaPosted Sep 20, 2018, 9:08 AM
Hello sir... I have added one component - loginpage. Now, in file - loginpage.components.html - I have done the css. But when I run the app, nothing is seen on web browser.
Riddhi ValechaPosted Sep 17, 2018, 8:22 AM
Meaning - one component for Design for entire website - Just like we use one Master Page for multiple .aspx pages in asp.net website?
Riddhi ValechaPosted Sep 14, 2018, 6:09 AM
Dear sir, I have read about the routing from youtube. I need help in designing part. How do I make one common design in one component and use the same design for other components ?
Riddhi ValechaPosted Sep 10, 2018, 1:43 PM
Hello sir .... I have finally succeed in setting up with my VS CODE and Angular 4. I have one query about this... In ASP.NET - we have Master Pages that we use to design the website template... What do we do to make templates in Angular4.
Riddhi ValechaPosted Jun 19, 2018, 6:17 AM
Hi... I also need help in connecting it with SQL SERVER - Windows Authentication. Eg - https://stackoverflow.com/questions/50252459/visual-studio-code-sql-server-connection-to-encrypted-database-with-azure-key-va
Riddhi ValechaPosted May 30, 2018, 5:50 AM
My Requirement is - I have to do CRUD Operations in VS CODE And Angular 2. I am able to connect it to SQL Server DB, but how to proceed further?
Riddhi ValechaPosted May 30, 2018, 5:00 AM
Hi... I am also not able to do the steps from here - http://www.dotnetcurry.com/aspnet/1234/aspnet5-apps-using-visual-studio-code-vscode-yeoman
Riddhi ValechaPosted May 30, 2018, 4:24 AM
THe command - npm install -g @angular/cli@latest D:\Portals\VSCODE\AngularJS_DEMO - This is giving an error - Could not install npm. . package.json file not found.
Riddhi ValechaPosted May 29, 2018, 4:44 AM
Hello sir... My version is - Angular 2. Error - package.json file not found.
Riddhi ValechaPosted May 29, 2018, 1:24 AM
Hello sir.... I am using Angular 2.... But, when I execute the command - install -g @angular/cli@latest - the files are in C:\Users\Riddhi\Roaming folder... As you said .. It install the package globally... But after creating a project successfully, when I run the command - cd new-ang-app - It gives an error that the package.json file is not found
Riddhi ValechaPosted May 28, 2018, 5:09 AM
Is there a way to set that path ?
Riddhi ValechaPosted May 28, 2018, 5:09 AM
How to install the - npm install -g @angular/cli@latest in that folder - D:\Portals\VSCODE\AngularJS_DEMO
Riddhi ValechaPosted May 28, 2018, 5:08 AM
Hello sir... I have a query... My folder for AngularJS Project is in D:\Portals\VSCODE\AngularJS_DEMO
Bhairab DuttPosted May 2, 2018, 7:16 AM
Thanks a lot ........
Deepak VermaPosted May 2, 2018, 7:07 AM
Great article sir............
Bhairab DuttPosted May 2, 2018, 1:41 AM
Thanks a lot Sir :)
Khumana RamPosted May 2, 2018, 1:36 AM
Awesome post and great overview about Angular CLI.... Keep it up B.D. sir
Bhairab DuttPosted Mar 29, 2018, 5:25 AM
Thanks a lot......
Mahesh VermaPosted Mar 29, 2018, 5:12 AM
Nice Bhairab Sir.........