ng-serve
builds an Angular application and starts a development server
TLDR
SYNOPSIS
ng serve [project] [options]ng dev [project] [options]ng s [project] [options]
DESCRIPTION
ng serve builds an Angular application and starts a development server. It watches for file changes and automatically rebuilds, with live reload or hot module replacement updating the browser.With the default application builder (esbuild), the development server is based on Vite. Builds are kept in memory; nothing is written to dist/.This is the primary command for Angular development workflow.
PARAMETERS
--port port
Port to listen on (default 4200).-o, --open
Open the URL in the default browser.--host host
Host to listen on (default localhost).-c, --configuration name
Named build configuration(s) from angular.json, comma-separated (e.g. development, production).--proxy-config file
Proxy configuration file for forwarding requests to a backend.--ssl
Serve using HTTPS (a self-signed certificate is generated unless --ssl-cert and --ssl-key are given).--ssl-cert file, --ssl-key file
SSL certificate and key to use for HTTPS.--allowed-hosts
Hosts the development server responds to (Vite allowedHosts option).--serve-path path
Pathname where the application is served.--headers headers
Custom HTTP headers added to all responses.--hmr
Hot module replacement (defaults to the live-reload setting).--live-reload
Reload the page on change (default true).--watch
Rebuild on change (default true).--poll ms
Use polling for file watching with the given interval.--prebundle
Vite dependency prebundling (default true).--define KEY=VALUE
Replace global identifiers with constant values.--inspect host:port
Activate the Node.js debugging inspector (SSR/SSG only).--build-target target
Build target to serve, as project:target[:configuration].--verbose
More detailed output logging.
PROXY CONFIG
{
"/api": {
"target": "http://localhost:3000",
"secure": false
}
}
CAVEATS
Development only; use ng build for production deployments. The default configuration for serve is development. Binding to 0.0.0.0 exposes the dev server on the network. Must be run inside an Angular workspace.
HISTORY
Angular CLI's serve command was introduced with Angular CLI in 2016, initially backed by webpack-dev-server. Since Angular 17 new projects use the esbuild-based application builder with a Vite dev server. Recent versions also accept ng dev as an alias.
