Angular warns that defaultProject is an invalid workspace extension
Workspace 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.
Fix it fast
1Find out which cause you have
Search angular.json for the key the message names.
grep -n 'defaultProject' angular.json2Match what you see, then jump to its fix
- 1
Workspace extension with invalid name (defaultProject) found.An old defaultProject key is still in angular.jsonFix - 2
Cannot determine project for command. This is a multi-project workspace...Commands now fail from the workspace root after the key is removedFix - 3
Workspace 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
- 1
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.json2Fix
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 buildConfirmed by github.com
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.json2Fix
Pass the project name, or change into the project folder before running the command.
ng serve my-app
# or
cd projects/my-app && ng serve3Verify
The command runs for the named project.
ng build my-appConfirmed by github.com
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.json2Fix
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 buildConfirmed by raw.githubusercontent.com
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 fixBack end
ng fails with Cannot find module @angular/cli/bin/ng
Cannot find module '@angular/cli/bin/ng'
The ng command is the entry point to the Angular CLI package.
2 causes, each with a fixBack end
Angular app shows 'Cannot GET /' when served by a Node.js server
Cannot GET /dashboard
Cannot GET / is Express saying no route or file matches the request.
3 causes, each with a fixBack 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 fixBack end
Angular build says it cannot resolve '@angular/localize/init'
Can't resolve '@angular/localize/init' in '/usr/src/app/src'
The build imports @angular/localize, and that package is not in node_modules.
2 causes, each with a fixBack end
The command npm run build -- --prod exited with code 1 (Angular)
The command "npm run build -- --prod" exited with code 1
Exit code 1 only says the build failed; the real message is above it.
2 causes, each with a fix