Angular-cli: Cannot use same target name in angular.json for multiple projects

Created on 20 Sep 2018  路  8Comments  路  Source: angular/angular-cli

Bug Report or Feature Request (mark with an x)

- [ X ] bug report

Command (mark with an x)

- [ X ] build
- [ X ] serve

Versions


7.0.0-beta.3 and 4.

Repro steps


Using an angular.json with multiple projects sharing the target name (ie, 'serve' and 'build' under the 'architect' node) will cause this error, even when specifying the project (ie. not a multiTarget). A recent change here caused this regression. It will give the error 'Could not determine a single project for the 'serve' target.' from within the call to getProjectNamesByTarget(), even though I have specified the project.

  "projects": {
    "stuff": {
      "architect": {
        "build": {

        }
      }
    },
    "morestuff": {
      "architect": {
        "build": {

The log given by the failure


Error: Could not determine a single project for the 'serve' target.
at ServeCommand.getProjectNamesByTarget (/Stuff/Spore/Typescript/node_modules/@angular/cli/models/architect-command.js:167:19)
at ServeCommand.initialize (/Stuff/Spore/Typescript/node_modules/@angular/cli/models/architect-command.js:75:39)
at process._tickCallback (internal/process/next_tick.js:68:7)
at Function.Module.runMain (internal/modules/cjs/loader.js:746:11)
at startup (internal/bootstrap/node.js:238:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:572:3)

Desired functionality


Ability to still use the same target names, 'build', 'serve', etc... across numerous projects in the same angular.json. A workaround is to use unique names.

angulacli devkibuild-angular regression bufix

All 8 comments

The error Could not determine a single project for the 'serve' target. is indicated that it cannot locate a single project when you use build and run. Thus in order to use the these builders you'd need to provide the project name as an argument.

Ex;

$ ng serve morestuff 

Yup. This error occurs even when that is done.

@alan-agius4 can you please reopen?

I checked a bit regarding this, and it seems it happens when you don't have a defaultProject set.

I can, if you give me a min. getProjectNamesByTarget() is designed to get the default project for all non multiTargets (which this is). target will be set to 'build' or 'serve' and there is no check to see if targetSpec.project is set.

err...ya, ok ill skip the repro unless you poke me again.

Oh, and its not the defaultProject, because I do have that set. (theres also another issue with that i think). Its that targetSpec.project.

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings