LinuxCommandLibrary

ng-serve

TLDR

Start development server

$ ng serve
copy
Serve on specific port
$ ng serve --port [4200]
copy
Serve and open browser
$ ng serve --open
copy
Serve specific project
$ ng serve [project-name]
copy
Serve with production config
$ ng serve --configuration=production
copy
Serve with proxy
$ ng serve --proxy-config [proxy.conf.json]
copy

SYNOPSIS

ng serve [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 updating the browser.
This is the primary command for Angular development workflow.

PARAMETERS

--port port

Port number.
--open, -o
Open in browser.
--host host
Bind address.
--configuration name
Build configuration.
--proxy-config file
Proxy configuration.
--ssl
Enable HTTPS.
--watch
Rebuild on changes (default).
--live-reload
Enable live reload.

PROXY CONFIG

$ // proxy.conf.json
{
  "/api": {
    "target": "http://localhost:3000",
    "secure": false
  }
}
copy

CAVEATS

Development only; use ng build for production. Memory-intensive for large projects. Part of Angular CLI.

HISTORY

Angular CLI's serve command was introduced with Angular CLI in 2016, providing a complete development server solution for Angular applications.

SEE ALSO

ng(1), webpack(1), vite(1)

Copied to clipboard