Skip to content

Resolving 'Workspace extension with invalid name (defaultProject) found' in Angular

Problem

When running ng serve in an Angular project, encountering the error:
Workspace extension with invalid name (defaultProject) found.

This issue occurs due to a deprecated configuration property in your angular.json file. Attempts to resolve it via dependency fixes like npm install --legacy-peer-deps are ineffective since it’s unrelated to package installations.

Solution

Remove the Deprecated defaultProject Property

Modern Angular CLI versions (≥v6) no longer require the defaultProject property. Its presence triggers the error. Here’s how to resolve it:

  1. Open angular.json in your project root
  2. Locate the top-level defaultProject entry (usually near the file’s beginning)
  3. Delete the line containing "defaultProject": "your-project-name"
  4. Save the file and re-run ng serve
json
{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "defaultProject": "my-app", 
  "newProjectRoot": "projects",
  "projects": {
    "my-app": { ... }
  }
}
json
{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "my-app": { ... }
  }
}

What If You Have Multiple Projects?

If your workspace contains multiple projects:

  1. Remove defaultProject from angular.json (it’s deprecated regardless)
  2. Explicitly specify the project when running CLI commands:
    bash
    ng serve your-main-project-name
    ng build your-secondary-project

Why This Works

The defaultProject property was deprecated in Angular CLI v6+ (GitHub Issue #11111) and became non-functional. Newer CLI versions treat it as an invalid workspace extension, causing the error. Removing it aligns your configuration with current Angular standards.

WARNING

Manually adding defaultProject to newer Angular projects creates conflicts. The CLI automatically uses your first project as default.

Best Practices

  1. Avoid manual edits to angular.json: Use CLI commands like ng new or ng generate application to manage projects
  2. Verify Angular CLI version: Ensure you’re using a recent version (check with ng version)
  3. Version control: Commit changes before modifying configuration files for easy rollback

Summary:
Eliminating the obsolete defaultProject from angular.json resolves this error immediately. The Angular CLI no longer supports this property, and your project will function correctly without it regardless of its type or complexity.