Angular Get Started
The Angular CLI is the fastest, most reliable way to create, run, and build an Angular application from your terminal.
Installing the Angular CLI
The Angular CLI (Command Line Interface) is a Node.js package that scaffolds projects, generates code, runs a development server, and produces optimized production builds. It is installed once, globally, and then used from any project folder.
Install the CLI globally
// This is a terminal/CLI reference, not runnable Angular code — commented out
// so it compiles as a harmless no-op instead of a syntax error.
// npm install -g @angular/cli
// # Verify the installation
// ng versionCreating a New Project
The ng new command scaffolds a complete, ready-to-run application: folder structure, configuration files, a starter component, and a test setup. Modern Angular defaults to standalone components, so no root NgModule is generated unless you opt into one.
Scaffold a new application
// This is a terminal/CLI reference, not runnable Angular code — commented out
// so it compiles as a harmless no-op instead of a syntax error.
// ng new my-first-app
// # The CLI will prompt for options:
// # - Add Angular routing? (Yes)
// # - Which stylesheet format? (CSS)
// cd my-first-app- ng new <name> - creates a new application in a folder called <name>
- ng serve - starts a local development server with live reload
- ng generate component <name> - scaffolds a new component
- ng build - produces an optimized, deployable build in the dist/ folder
- ng test - runs unit tests with Karma or Jest, depending on configuration
Running the Development Server
Once inside the project folder, ng serve compiles the application and serves it locally, watching your files for changes. Any edit to a component, template, or stylesheet triggers an automatic rebuild and refreshes the browser.
Start the dev server
// This is a terminal/CLI reference, not runnable Angular code — commented out
// so it compiles as a harmless no-op instead of a syntax error.
// ng serve
// # Or specify a port and open the browser automatically
// ng serve --port 4300 --openExercise: Angular Get Started
What is the recommended way to create a new Angular project?