![Forrest logo](/images/logo.png)
ng:tldr:31e0f
The command ng serve
is used in Angular projects to start a development server. It compiles the project, launches the server, and watches for any changes made to the source code files. It is a commonly used command during the development process to quickly test and preview the application.
When you run ng serve
, Angular CLI (Command Line Interface) scans the project files and compiles all the Angular components, templates, stylesheets, and assets. It also creates a development server that can be accessed through a specified local URL. By default, the URL is http://localhost:4200
.
The development server provides a live-reload feature which means that any changes you make to the code will automatically trigger a recompilation and update the running application in the browser. This eliminates the need to manually stop and restart the server after each change.
Running ng serve
also gives you access to additional features like error messages and build logs in the terminal or command prompt window. This is helpful for debugging as it shows any issues or errors that occur during the compilation process.
In summary, the ng serve
command is used to build and serve an Angular project locally, providing a live-reload development server that automatically updates the application in real-time as you make changes to the code.