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-hostsList of hosts that are allowed to access the dev server.--aotDeprecated: Use the "aot" option in the browser builder instead. Build using Ahead of Time compilation.--base-hrefDeprecated: Use the "baseHref" option in the browser builder instead. Base url for the application being built.--browser-targetA 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-chunkDeprecated: Use the "commonChunk" option in the browser builder instead. Generate a seperate bundle containing code used across multiple bundles.--configurationOne 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-urlDeprecated: Use the "deployUrl" option in the browser builder instead. URL where files will be deployed.--disable-host-check default:falseDon't verify connected clients are part of allowed hosts.--help default:falseShows a help message for this command in the console.--hmr default:falseEnable hot module replacement.--hmr-warning default:trueDeprecated: No longer has an effect. Show a warning when the --hmr option is enabled.--host default:localhostHost to listen on.--live-reload default:trueWhether to reload the page on change, using live-reload.--open default:falseOpens the url in default browser. Aliases: -o--optimizationDeprecated: 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.--pollEnable and define the file watching poll time period in milliseconds.--port default:4200Port to listen on.--prodDeprecated: 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.--progressDeprecated: Use the "progress" option in the browser builder instead. Log progress to the console while building.--proxy-configProxy configuration file.--public-hostThe 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-pathThe pathname where the app will be served.--serve-path-default-warning default:trueDeprecated: No longer has an effect. Show a warning when deploy-url/base-href use unsupported serve path values.--source-mapDeprecated: Use the "sourceMap" option in the browser builder instead. Output source maps for scripts and styles.--ssl default:falseServe using HTTPS.--ssl-certSSL certificate to use for serving HTTPS.--ssl-keySSL key to use for serving HTTPS.--vendor-chunkDeprecated: Use the "vendorChunk" option in the browser builder instead. Generate a seperate bundle containing only vendor libraries. This option should only used for development.--verboseAdds more details to output logging.--watch default:trueRebuild on change.