Migrating your Angular project to version 14 will automatically remove the defaultProject property in angular.json for single project workspaces.

Let’s understand what defaultProject is and when you might need it.

What is default project in Angular?

In Angular, a “default project” refers to the primary application or module within an Angular workspace.

An Angular workspace is essentially a project container that can hold multiple projects, each of which can be an Angular application, library, or other related modules.

When you create a new Angular workspace using the Angular CLI, it automatically generates a default project for you.

ng new my-angular-appCode language: Bash (bash)

This default project is often named “app” by default.

It serves as the main entry point for your application and includes the initial components, modules, services, and other files necessary to get your Angular application up and running.

You can also specify a different name for the default project during the creation of the workspace using the --defaultProject flag:

ng new my-angular-app --defaultProject=my-default-appCode language: Bash (bash)

In this case, the default project is going to be “my-default-app” instead of the usual “app.”

Why do we need to specify defaultProject in Angular?

You can have multiple projects within a single Angular workspace e.g., an admin panel and a user-facing frontend.

Each project can have its own configuration, dependencies, and codebase.But they can also share common resources and libraries within the workspace.

Angular CLI assumes you may create multiple projects in your workspace. And tries to help you by specifying the default project for you.

Does angular require defaultProject in angular json file?

Angular itself does not require a defaultProject in the angular.json file.

The defaultProject property is completely optional. It specifies which project to build & serve when a project name is not provided in the command line.

However, there is an exception.

If you have multiple projects in your workspace and you’re running a command that requires a project name (like ng serve or ng build) without specifying a project, then defaultProject is needed to tell Angular which project to apply the command to.

If you only have one project in your workspace, or you always specify your project when running commands, then you don’t need defaultProject.

In conclusion, Angular 14 (or any version) does not require defaultProject, but it can be helpful in multi-project workspaces.

Umut Esen

Software Engineer specialising in full-stack web application development.

Leave a Reply