Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

Angular warns that defaultProject is an invalid workspace extension

ErrorWorkspace extension with invalid name (defaultProject) found.

Short answer

The defaultProject option was removed from angular.json, so a newer CLI treats the leftover key as an unknown workspace extension. Delete the key. The CLI now picks the project from your current folder, so run ng from inside the project or pass the project name.

  • Applies to Angular CLI 20, Angular CLI 21, Node.js 22
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Search angular.json for the key the message names.

    grep -n 'defaultProject' angular.json
  2. 2Match what you see, then jump to its fix

    1. 1Workspace extension with invalid name (defaultProject) found.An old defaultProject key is still in angular.jsonFix
    2. 2Cannot determine project for command. This is a multi-project workspace...Commands now fail from the workspace root after the key is removedFix
    3. 3Workspace extension with invalid name (somekey) found. or Project 'my-app' contains extension with invalid name (somekey).Another custom key sits at the top level or inside a projectFix

What does the error look like?

  • Workspace extension with invalid name (defaultProject) found.
  • Project 'my-app' contains extension with invalid name

Cause 1 of 3

An old defaultProject key is still in angular.json

1Check

The CLI flags a top-level key as invalid unless it is a known one (cli, newProjectRoot, schematics) or starts with a short lowercase prefix and a hyphen. defaultProject is no longer known.

grep -n -B1 -A1 'defaultProject' angular.json

2Fix

Delete the line. The CLI chooses the project from the folder you run it in (or the only project, if there is one), so nothing replaces it.

// delete this line from the top level of angular.json
"defaultProject": "my-app",

3Verify

Run a command that reads the workspace; the warning is gone.

ng build

Confirmed by github.com

Did this fix it?

Cause 2 of 3

Commands now fail from the workspace root after the key is removed

1Check

With several projects, the CLI no longer reads a default. From the root folder it cannot tell which project you mean.

grep -n '"root"' angular.json

2Fix

Pass the project name, or change into the project folder before running the command.

ng serve my-app
# or
cd projects/my-app && ng serve

3Verify

The command runs for the named project.

ng build my-app

Confirmed by github.com

Did this fix it?

Cause 3 of 3

Another custom key sits at the top level or inside a project

1Check

Tools sometimes add their own keys to angular.json. The CLI accepts a custom key only if its name starts with one to three lowercase letters and a hyphen, such as x-mytool.

grep -n 'somekey' angular.json

2Fix

Remove the key if nothing uses it, or rename it with a prefix such as x-, and update the tool that reads it.

// before
"myToolSettings": { }
// after
"x-myToolSettings": { }

3Verify

The message no longer appears.

ng build

Confirmed by raw.githubusercontent.com

Did this fix it?

How do I stop it coming back?

  • After ng update, read the angular.json diff; the migration removes defaultProject for you.
  • Name custom keys with an x- prefix from the start.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Back end

ng serve says it cannot determine the project or target

Cannot determine project for command.

The Angular CLI looked through angular.json for a project that defines the target you asked for (serve, build, test) and found none, or found several and could not pick one.

3 causes, each with a fix

Back end

ng serve cannot find the dev-server builder package

Could not find the implementation for builder @angular/build:dev-server

The builder named in angular.json (for example @angular-devkit/build-angular:dev-server) is looked up as an npm package starting from the workspace root.

3 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.