Installation Guide

This guide covers installing Angular and setting up your development environment so you can get started quickly.

Prerequisites

Before installing Angular, make sure your system meets these requirements:

  • Node.js: Version 18.10.0 or higher recommended
  • npm: Comes with Node.js, version 6.x or higher
  • Operating System: Windows, macOS, or Linux

Installing Angular CLI

Angular CLI is the official command-line tool for creating and managing Angular projects.

Global Installation

npm install -g @angular/cli

Verify Installation

ng version

If successful, you'll see the Angular CLI version information.

Installing a Specific Version

If you need a particular version:

npm install -g @angular/cli@17

Creating a New Project

Using CLI

ng new my-app

This creates a new project called "my-app" and automatically installs dependencies.

Creating with Options

# Create without installing dependencies
ng new my-app --skip-install

# Use SCSS for styles
ng new my-app --style=scss

# Enable routing
ng new my-app --routing

# Create standalone components (Angular 14+)
ng new my-app --standalone

Development Environment Setup

Using Chinese Mirrors

Due to network issues, it's recommended to configure a Chinese mirror:

# Set npm registry
npm config set registry https://registry.npmmirror.com

# Or use nrm to manage registries
npm install -g nrm
nrm use taobao

Installing Node.js

Using nvm (recommended):

# Install nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash

# Install Node.js LTS version
nvm install --lts
nvm use --lts

Windows using nvm-windows:

Download the installer from https://github.com/coreybutler/nvm-windows

Starting the Development Server

cd my-app

Start Development Server

ng serve

Default address: http://localhost:4200

Live Reload

Angular CLI supports live reload—your browser refreshes automatically when you make code changes.

Building for Production

Build Command

ng build

Output goes to the dist directory.

Production Optimization

ng build --configuration=production

This enables minification, tree-shaking, and other optimizations.

Common CLI Commands

CommandDescription
ng generate component xxxGenerate a component
ng generate service xxxGenerate a service
ng generate module xxxGenerate a module
ng generate directive xxxGenerate a directive
ng generate pipe xxxGenerate a pipe
ng generate guard xxxGenerate a route guard

Development Tools

VS Code Extensions

  • Angular Language Service: Provides template type checking and autocompletion
  • Angular Snippets: Common code snippets
  • Prettier: Code formatting

Debugging

Angular provides the Angular DevTools browser extension for debugging and performance profiling.

Uninstalling Angular CLI

If you need to remove it:

npm uninstall -g @angular/cli

Next Steps

After installation, we recommend reading these docs to learn more:

  • User Manual - Components, services, routing, and more
  • FAQ - Common questions and answers