So, you decided to learn Angular and don’t know the difference between ng build and ng serve. Well, luckily for you, we are going to explain how these two commands work!
What Is ng serve In Angular?
The ng serve command is really useful while you are developing your Angular application. It launches the server, watches your files, and rebuilds the app as you make changes. All of these processes will happen from memory and allows fast, local deployments as you build your application.
ng serve is essentially putting Angular into development mode and giving you all the tools necessary to have a smooth development experience. It is a really important command to know if you’re going to be working in Angular!
What Is ng build In Angular?
ng build is the command you use in Angular when you have finished your application and are ready to deploy it to a remote server. You cannot use ng serve for this process. The main purpose of ng build is to generate the build artifacts and create an output folder to deploy elsewhere.
Summary: What Is The Difference Between ng serve and ng build?
The difference between ng serve and ng build is that ng serve is used to support your development experience while ng build is used to build and deploy your finished project.
The ng serve builds artifacts from memory to keep the process fast. It does not create an output folder and cannot be used to deploy your application. It is only used as a development tool. In order to deploy your application, you must use ng build
Hopefully, this article helped you understand the difference between these two commands. If you’re new to Angular and trying to learn this frontend framework, check out this best-selling course!