Maaz Zindani

Loading the index…

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

ng serve says it cannot determine the project or target

ErrorCannot 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.

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

Fix it fast

  1. 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.json
  2. 2Match what you see, then jump to its fix

    1. 1Cannot determine project or target for command.No project in angular.json defines the targetFix
    2. 2Cannot 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. 3Cannot find "serve" target for the specified project.The project you named has no such targetFix

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.json

2Fix

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 serve

Confirmed by raw.githubusercontent.com

Did this fix it?

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.json

2Fix

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 serve

3Verify

The dev server starts for the project you named.

ng serve my-app

Confirmed by raw.githubusercontent.com

Did this fix it?

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.json

2Fix

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-app

3Verify

The command finds its target and starts.

ng build my-app

Confirmed by raw.githubusercontent.com

Did this fix it?

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 fix

Next step

Want this handled for good?

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