ng serve says it cannot determine the project or target
Cannot determine project or target for command.Short answer
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. List the projects and their targets in angular.json, then pass the project name or add the missing target.
Fix it fast
1Find out which cause you have
Open angular.json and list which projects have which targets. The CLI only runs a target that a project defines under architect.
grep -n -E '"(projects|architect|serve|build|test)"|"builder"' angular.json2Match what you see, then jump to its fix
- 1
Cannot determine project or target for command.No project in angular.json defines the targetFix - 2
Cannot determine project for command. This is a multi-project workspace and more than one project supports this command.A multi-project workspace and the CLI cannot pick one projectFix - 3
Cannot find "serve" target for the specified project.The project you named has no such targetFix
- 1
What does the error look like?
Cannot determine project or target for command.Cannot determine project for command.This is a multi-project workspace and more than one project supports this command.Cannot find "serve" target for the specified project.
Cause 1 of 3
No project in angular.json defines the target
1Check
The CLI collects every project that has the target you typed. If the list is empty it reports this message. It happens when the projects object is empty, when only libraries are left, or when the serve target was deleted.
grep -n '"serve"' angular.json
grep -n '"projects"' angular.json2Fix
Run the command for a project that has the target, or add the target back. For an application, the dev server target uses the @angular/build:dev-server builder.
// angular.json, under projects > my-app > architect
"serve": {
"builder": "@angular/build:dev-server"
}3Verify
Run the command again from the workspace folder.
ng serveConfirmed by raw.githubusercontent.com
Cause 2 of 3
A multi-project workspace and the CLI cannot pick one project
1Check
When several projects have the target, the CLI uses the project that contains your current folder. From the workspace root there is no such project, so it stops and prints the list of available projects.
pwd && grep -n '"root"' angular.json2Fix
Name the project on the command line, or change into that project's folder first. Since the defaultProject option was removed, angular.json can no longer choose for you.
ng serve my-app
# or
cd projects/my-app && ng serve3Verify
The dev server starts for the project you named.
ng serve my-appConfirmed by raw.githubusercontent.com
Cause 3 of 3
The project you named has no such target
1Check
You passed a project name (or the CLI chose one) and that project does not define the target. A library, for example, has build but no serve.
grep -n -A3 '"serve"' angular.json2Fix
Serve an application project instead. If the CLI offers a package that provides the target in an interactive terminal, let it run ng add for you; otherwise add the target by hand as shown in the first cause.
ng serve my-app3Verify
The command finds its target and starts.
ng build my-appConfirmed by raw.githubusercontent.com
How do I stop it coming back?
- Run ng commands from inside the project folder in a multi-project workspace, or always pass the project name.
- Keep one application per project entry and give every application a serve target.
- After ng update, read the diff of angular.json before committing it.
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 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 warns that defaultProject is an invalid workspace extension
Project 'my-app' contains extension with invalid name
The defaultProject option was removed from angular.json, so a newer CLI treats the leftover key as an unknown workspace extension.
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
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