This Blog explains how to set up your environment for Angular development using the Angular CLI tool. It includes information about prerequisites, installing the CLI, and some of the issues arise, time of installation.
Prerequisites
Angular requires an active LTS or maintenance LTS version of Node.js.
Node.js is a cross-platform environment that runs and executes JavaScript codes outside the browser. It comes up with everything which is required to run a program written in JavaScript.
For setup node js you can follow bellow link .
https://radixweb.com/blog/installing-npm-and-nodejs-on-windows-and-mac
The Angular CLI is a command line interface tool that can create a project, add files, and perform a variety of ongoing development tasks such as testing, bundling, and deployment.
Install the CLI using the npm package manager run the bellow command in your terminal
Step 1: npm install -g @angular/cli
Now it’s time to create a basic Angular project on a development server. To create a project in Angular , you will use the following command
Step 2: ng new your-project-name
Let us now check whether Angular CLI is installed or not. To check your Angular version run the bellow command
Step 3: ng –version
The project “your-project-name” is created successfully. It installs all the required packages necessary for your project to run in Angular .
Now go to the your directory in the command line
Step 4. cd your-project-name
Now that we have the file structure for our project, let us compile our project and serve our project with bellow command
Step 5. ng serve
The web server starts on port 4200. Type the url http://localhost:4200/ in the browser and see the output. You will be directed to the following screen
Error occur while install Angular
The error in NPM, ‘error package install failed, see above’, can occur when the user creates a new project in Angular using Node.js using VS code.
To solve this problem. Follow each step one by one
Step 1: Connect your pc with internet
// verify your NPM cached memory
Step 2: npm cache verify
//clear your cache
Step 3: npm cache clear – force
//now install the latest Angular/CLI package.
Step 4: npm install –g @angular/cli@latest
Step 5: ng –version