Angular is a framework and platform for building client-side single-page applications using TypeScript and HTML. Since Angular is written in TypeScript, it uses its libraries for the functionalities we import into applications.
In this given article, we are going to discuss Angular CLI 12 and a step-by-step guide to installing Angular on Windows. Before that, let's understand what type of features Angular 12 offers:
So, now the question is, what is Angular CLI? And how can we use it? This tutorial will give you a better understanding of Angular CLI.
Angular CLI is an Angular tool created by the development team from Angular. It’s used to manage, build, maintain, and test Angular applications.
The Angular CLI is a command-line tool, which may trouble you if you prefer something with a good UI and is "simple to use." There is, in fact, a Visual Studio Code extension that can be downloaded and installed. It adds a Graphical User Interface (GUI) that can be utilized instead of the terminal.
Now, we have got some idea about the Angular CLI. And maybe, if you are wondering, do we need to use Angular CLI for the Angular development?
Well, the short answer is NO. But, it’s not a good approach if you haven't used it yet as an Angular developer.
Why?
Actually, Angular CLI was created to automate time-consuming tasks and enhance the development speed. It creates Angular starter apps with a .gitignore
file. It helps you build every element of an app, like pipes, app shells, components, skeleton modules, test handling, and other common operations.
Back in 2017, Angular released its first beta version Angular CLI. And since then, it has had over 450 versions.
With every new Angular framework coming into the market, a new Angular CLI version is released. So, if you are using Angular 12 right now, there will also be an Angular CLI 12 in the market. That is the Angular CLI latest version. This does not mean that the Angular CLI version must be the same as the Angular project version. The majority of the time, they aren't. In your Angular project, you can use a different version of the Angular CLI.
Create an Angular App with Angular CLI
Initiate the Development
Before coming to the actual topic of Angular CLI 12 installations, you will need to set up a development environment for front-end development with Angular.
You should be ready with the following things:
Once Node.js is installed, check its version with the following commands:
node -v
npm -v
With Angular CLI, you can create apps and library code. Also, it lets you perform multiple ongoing development tasks, like bundling, testing, and deployment.
You can install it using NPM. So, open your Powershell or Command Prompt first and write the given command to install Angular CLI.
npm install -g @angular/cli
/usr/bin/ng -> /usr/lib/node_modules/@angular/cli/bin/ng
> @angular/cli@10.1.1 postinstall /usr/lib/node_modules/@angular/cli
> node ./bin/postinstall/script.js
? Would you like to share anonymous usage data with the Angular Team at Google under
Google’s Privacy Policy at https://policies.google.com/privacy? For more details and
how to change this setting, see http://angular.io/analytics. Yes
+ @angular/cli@10.1.1
added 277 packages from 207 contributors in 19.024s
If you agree, press Y; otherwise, N. This answer won’t affect the Angular installation.
Now check the Angular version with the below command.
ng --version
Sample Output
Angular CLI: 10.1.1
Node: 12.18.3
OS: linux x64
Angular:
...
Ivy Workspace:
Package Version
------------------------------------------------------
@angular-devkit/architect 0.1001.1
@angular-devkit/core 10.1.1
@angular-devkit/schematics 10.1.1
@schematics/angular 10.1.1
@schematics/update 0.1001.1
rxjs 6.6.2
Angular CLI is successfully installed on your Windows. Now, you can configure a workspace to create a new Angular project named app-project.
ng new app-project
Output:
.....
......
added 1167 packages from 1048 contributors and audited 19053 packages in 72.14s
23 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
Successfully initialized git.
Once your test app project is created successfully, run your app using ng serve
command.
cd app-project
ng serve --open
This starts the server, monitors our files, and rebuilds the app as those files change. The browser will automatically open to the address http://localhost:4200
when we use the –-open (or just -o) option.
Finally, the process of installing Angular CLI on Windows 10 is completed.
Here’s what your Angular project will look like in the browser.
Source: angularangular.ioio
The Angular application can be modularized using Angular modules. In other words, Angular modules are used to separate the Angular app into specific sections.
To create a basic Angular module, use the given Angular CLI command.
ng generate module MyModuleName
You might need more than just an Angular module as per requirements. Here's an Angular CLI command you can use to create an Angular module with its own routing module.
ng generate module MyModuleName --routing
To create a new Angular component, let’s write down the below Angular CLI command.
ng generate component MyComponentName
In case you want to build your own component, then with the following command, you can make it possible.
ng generate component MyComponentName --module MyModuleName
Want to Create a Feature-rich Angular App?
Leverage Our Services
You can execute the below command to create custom pipes.
ng generate pipe MyPipeName
To create a new service, follow below given command.
ng generate service MyServiceName
You've now understood how to install Angular CLI 12 on Windows and use it to create an Angular project that works. Thankfully, installing the Angular CLI process is the same for every version of the Windows operating system.
Moreover, you have also understood creating various Angular items like modules, components, and services for your project. It hardly takes much time to completely install and set up an Angular app once you have installed Node.js (NPM) and Angular CLI onto your system.
If you still face any issues while installing Angular CLI or developing an Angular application, you can hire Angular developers from an experienced company – Radixweb. Our expertise and industry knowledge will help you develop a feature-rich Angular application in a short time. So, what are you waiting for? Get in touch with us now!
Ready to brush up on something new? We've got more to read right this way.