This article will show you how to use the Angular CLI tool for angular installation to set up your Angular development environment. It covers requirements, installing the CLI, setting up an initial workspace and starter application, and testing your setup locally.
If you want a quick overview about angular framework then you can follow the article on “Introduction of angular framework“.
To use the Angular framework, you should be familiar with the following:
Knowledge of TypeScript is helpful, but not required.
- Node.js Angular requires an active LTS or maintenance LTS version of Node.js. For more information on installing Node.js, see nodejs.org. If you are unsure what version of Node.js runs on your system, run
node -vin a terminal window.
- npm package manager Angular, the Angular CLI, and Angular applications depend on npm packages for many features and functions. To download and install npm packages, you need an npm package manager. This guide uses the npm client command line interface, which is installed with
Node.jsby default. To check that you have the npm client installed, run
npm -vin a terminal window.
Angular Installation Using CLI
You use the Angular CLI to create projects, generate application and library code, and perform a variety of ongoing development tasks such as testing, bundling, and deployment.
To install the Angular CLI, open a terminal window and run the following command:
npm install -g @angular/cli
Create a workspace and initial application
You develop apps in the context of an Angular workspace.
To create a new workspace and initial starter app:
- Run the CLI command
ng newand provide the name
my-app, as shown here:
ng new my-app
ng new command prompts you for information about features to include in the initial app. Accept the defaults by pressing the Enter or Return key.
The Angular CLI installs the necessary Angular npm packages and other dependencies. This can take a few minutes.
The CLI creates a new workspace and a simple Welcome app, ready to run.
The Angular CLI includes a server, for you to build and serve your app locally.
- Navigate to the workspace folder, such as
- Run the following command:
cd my-app ng serve --open
ng serve command launches the server, watches your files, and rebuilds the app as you make changes to those files.
--open (or just
-o) option automatically opens your browser to
If your installation and setup was successful, you should see a page similar to the following.