Getting Started

Angular Environment Setup

Install Node.js, npm, and the Angular CLI. Create your first Angular project and explore the development workflow.

Prerequisites

Before setting up Angular, make sure you have:

  • Node.js (version 18.x or later) โ€” Angular requires a modern Node.js runtime
  • npm (comes with Node.js) or yarn as a package manager
  • A code editor โ€” Visual Studio Code is recommended for the best Angular experience

Step 1: Install Node.js

Download and install Node.js from the official website:

๐Ÿ‘‰ https://nodejs.org

Choose the LTS (Long Term Support) version for stability.

After installation, verify in your terminal:

bash
node --version
# v20.x.x

npm --version
# 10.x.x

Step 2: Install the Angular CLI

The Angular CLI (Command Line Interface) is the official tool for creating, developing, and managing Angular projects.

bash
npm install -g @angular/cli

Verify the installation:

bash
ng version

You should see output similar to:

Angular CLI: 19.x.x
Node: 20.x.x
Package Manager: npm 10.x.x

Step 3: Create Your First Project

Use the CLI to generate a new Angular application:

bash
ng new my-first-app

The CLI will ask you several questions:

PromptRecommended Choice
Which stylesheet format?CSS (or SCSS if you prefer)
Enable Server-Side Rendering?No (for now)

The CLI creates a project directory with all necessary files and installs dependencies automatically.

Step 4: Run the Development Server

Navigate into your project and start the dev server:

bash
cd my-first-app
ng serve

Open your browser and visit:

http://localhost:4200

You should see the default Angular welcome page. The dev server supports hot module replacement โ€” changes you make are reflected instantly in the browser.

Step 5: VS Code Extensions

For the best development experience, install these VS Code extensions:

ExtensionPurpose
Angular Language ServiceAutocomplete, error checking in templates
ESLintCode linting
PrettierCode formatting
Angular SnippetsCode snippet shortcuts

Useful CLI Commands

Here are the most common Angular CLI commands you'll use:

bash
# Create a new component
ng generate component my-component
# Shorthand: ng g c my-component

# Create a new service
ng generate service my-service

# Create a new module
ng generate module my-module

# Run unit tests
ng test

# Build for production
ng build

# Run lint checks
ng lint

Project Configuration Files

FilePurpose
angular.jsonWorkspace and project configuration
tsconfig.jsonTypeScript compiler configuration
package.jsonDependencies and scripts
.editorconfigEditor formatting rules

Troubleshooting Common Issues

Permission Errors on npm Install

bash
# Use npx instead of global install
npx @angular/cli new my-app

# Or fix npm permissions
npm config set prefix ~/.npm-global

Port Already in Use

bash
# Use a different port
ng serve --port 4300

Node Version Mismatch

bash
# Use nvm to manage Node versions
nvm install 20
nvm use 20

Next Steps

With your environment set up and a running application, you're ready to explore the Angular project structure and understand how all the pieces fit together.