The Difference Between ‘ng build’ & ‘ng serve’ In Angular

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!

Grant Darling

Grant is a full-stack / frontend software developer passionate about writing & coding. He has many years experience working in the tech industry both as a freelancer and as an employee.

The Code Bytes is all about providing people with honest information about programming. To learn more about Grant, read his about page!

If you’re interested in freelance coding / writing services or want to partner with The Code Bytes, you can get in touch with me here!