How to use the Angular CLI serve command line

Created

ng serve is a great command to use when developing your application locally. It starts up a local development server, which will serve your application while you are developing it. It is not meant to be used for a production environment.

Builds and serves your app
ng serve
ng s
Alias for the command
ng run [project]:serve
Build at: 2021-06-29T01:46:17.730Z - Hash: 46ebb73a5e8b7c265ada - Time: 18490ms

** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **

✔ Compiled successfully.
✔ Browser application bundle generation complete.

Port to listen on.

Port
ng serve --port=4008
ng s --port=4008
Build at: 2021-06-29T01:49:43.345Z - Hash: 46ebb73a5e8b7c265ada - Time: 7333ms
** Angular Live Development Server is listening on localhost:4008, open your browser on http://localhost:4008/ **

The Angular CLI serve Help Commands and Options

Usage: 
  ng serve <project> [options]
  ng s <project> [options]

Arguments:
<project>
The name of the project to build. Can be an application or a library.
Options:
--allowed-hosts
List of hosts that are allowed to access the dev server.
--aot
Deprecated: Use the "aot" option in the browser builder instead. Build using Ahead of Time compilation.
--base-href
Deprecated: Use the "baseHref" option in the browser builder instead. Base url for the application being built.
--browser-target
A browser builder target to serve in the format of project:target[:configuration]. You can also pass in more than one configuration name as a comma-separated list. Example: project:target:production,staging.
--common-chunk
Deprecated: Use the "commonChunk" option in the browser builder instead. Generate a seperate bundle containing code used across multiple bundles.
--configuration
One or more named builder configurations as a comma-separated list as specified in the "configurations" section of angular.json. The builder uses the named configurations to run the given target. Setting this explicitly overrides the "--prod" flag. Aliases: -c
--deploy-url
Deprecated: Use the "deployUrl" option in the browser builder instead. URL where files will be deployed.
--disable-host-check default:false
Don't verify connected clients are part of allowed hosts.
--help default:false
Shows a help message for this command in the console.
--hmr default:false
Enable hot module replacement.
--hmr-warning default:true
Deprecated: No longer has an effect. Show a warning when the --hmr option is enabled.
--host default:localhost
Host to listen on.
--live-reload default:true
Whether to reload the page on change, using live-reload.
--open default:false
Opens the url in default browser. Aliases: -o
--optimization
Deprecated: Use the "optimization" option in the browser builder instead. Enables optimization of the build output. Including minification of scripts and styles, tree-shaking, dead-code elimination, tree-shaking and fonts inlining.
--poll
Enable and define the file watching poll time period in milliseconds.
--port default:4200
Port to listen on.
--prod
Deprecated: Use --configuration production instead. Shorthand for "--configuration=production". Set the build configuration to the production target. By default, the production target is set up in the workspace configuration such that all builds make use of bundling, limited tree-shaking, and also limited dead code elimination.
--progress
Deprecated: Use the "progress" option in the browser builder instead. Log progress to the console while building.
--proxy-config
Proxy configuration file.
--public-host
The URL that the browser client (or live-reload client, if enabled) should use to connect to the development server. Use for a complex dev server setup, such as one with reverse proxies.
--serve-path
The pathname where the app will be served.
--serve-path-default-warning default:true
Deprecated: No longer has an effect. Show a warning when deploy-url/base-href use unsupported serve path values.
--source-map
Deprecated: Use the "sourceMap" option in the browser builder instead. Output source maps for scripts and styles.
--ssl default:false
Serve using HTTPS.
--ssl-cert
SSL certificate to use for serving HTTPS.
--ssl-key
SSL key to use for serving HTTPS.
--vendor-chunk
Deprecated: Use the "vendorChunk" option in the browser builder instead. Generate a seperate bundle containing only vendor libraries. This option should only used for development.
--verbose
Adds more details to output logging.
--watch default:true
Rebuild on change.

Related Tags