Skip to content

Angular Setup

Getting Angular running locally takes only a few commands once you have the right tools installed. This lesson walks through installing Node.js, the Angular CLI, and creating your first project.

What You Need to Run Angular

Angular development requires Node.js (which provides npm, the package manager Angular's tooling relies on) and the Angular CLI, a command-line tool that generates projects, builds them, and starts a local development server.

You do not need to install a database, a separate web server, or any compiler by hand, the Angular CLI wraps all of that behind a small set of commands.

# check versions
node -v
npm -v

# install the Angular CLI globally
npm install -g @angular/cli

# confirm it installed
ng version

ng version prints the installed Angular CLI version along with any Angular packages detected in the current folder.

Creating and Running a New Project

ng new my-app
cd my-app
ng serve
  • ng new scaffolds a new project with sensible defaults (you can answer prompts for routing, styling, and SSR).
  • cd my-app moves into the generated project folder before running further commands.
  • ng serve starts a local dev server, by default at http://localhost:4200.
  • The dev server supports hot reload, saved changes appear in the browser almost instantly.

Angular Setup Cheatsheet

The essential commands you will run when starting a new Angular project.

Command Purpose
npm install -g @angular/cli Install the Angular CLI globally
ng version Check installed CLI and Angular versions
ng new my-app Create a new Angular project
cd my-app && ng serve Start the local development server
ng serve --open Start the dev server and open a browser tab
ng serve --port 4300 Run the dev server on a custom port
ng build Produce a production build in dist/

Installing Node.js and the Angular CLI

Angular officially supports Node.js LTS releases. Install Node from nodejs.org (or a version manager like nvm), then install the Angular CLI globally with npm so the ng command is available everywhere on your machine.

  • Prefer an even-numbered LTS Node.js release for the best compatibility.
  • Use nvm (Node Version Manager) if you need to switch Node versions between projects.
  • npm install -g @angular/cli makes the ng command globally available.
  • You can also use npx @angular/cli new my-app without a global install.

Answering the ng new Prompts

When you run ng new, the CLI asks a few configuration questions. Understanding these choices up front avoids surprises later.

Prompt Recommendation
Stylesheet format SCSS if your team uses Sass, otherwise plain CSS
Add Angular routing? Yes, for any app with more than one view
Server-side rendering (SSR)? Yes for SEO-sensitive public sites, optional otherwise

Everyday Project Scripts

Once a project exists, day-to-day work mostly involves ng serve while developing, ng build before deploying, and ng test when running unit tests.

ng serve          # start dev server with hot reload
ng build           # production build into dist/
ng build --watch   # rebuild automatically on file changes
ng test            # run unit tests

Common Mistakes

  • Installing an unsupported or very old Node.js version, causing cryptic CLI errors.
  • Running ng commands from the wrong folder (outside the generated project directory).
  • Forgetting to restart ng serve after changing angular.json or environment configuration files.
  • Installing the Angular CLI locally per-project and then expecting the global ng command to match its version.

Key Takeaways

  • Angular requires Node.js and npm as prerequisites for its tooling.
  • The Angular CLI (@angular/cli) scaffolds, serves, and builds projects.
  • ng new creates a new project; ng serve runs it locally with hot reload.
  • Choices made during ng new (routing, styles, SSR) can usually be changed later, but it's easier to pick correctly upfront.

Pro Tip

Run npx @angular/cli new my-app even if you never installed the CLI globally, npx will fetch and run the latest CLI version on demand, avoiding version mismatches across machines.