Skip to content

ng build and ng serve with --project should clearly indicate that a project is unrecognized #17682

@lonerzzz

Description

@lonerzzz

🐞 Bug report

Command (mark with an x)

  • new
  • build
  • serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • xi18n
  • run
  • config
  • help
  • version
  • doc

Is this a regression?

Suspect that this problem has existed from day one.

Description

When running 'ng build --project ' or 'ng serve --project ', the command gives a misleading error if the project name is not recognized. In the following example, 'Typo' is a project that has not even been created.

ng build --project Typo
An unhandled exception occurred: Project 'Typo' does not support the 'build' target.
See "C:\Users\Jason\AppData\Local\Temp\ng-nSmh2j\angular-errors.log" for further details.

Nothing about the error indicates that 'Typo' could not be found in the angular.json file and so starts a wild goose chase. I have been bitten by this twice at separate times when I have stepped away from the tools for a bit. A simple typo in the name of the project is enough to send one looking in the json file for errors when that is not the problem.

🔬 Minimal Reproduction

See above in the description.

🔥 Exception or Error

See above description

🌍 Your Environment



     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 9.1.5
Node: 10.13.0
OS: win32 x64

Angular: 9.1.6
... animations, common, compiler, compiler-cli, core, forms
... language-service, localize, platform-browser
... platform-browser-dynamic, router
Ivy Workspace: Yes

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.901.5
@angular-devkit/build-angular      0.901.5
@angular-devkit/build-ng-packagr   0.901.5
@angular-devkit/build-optimizer    0.901.5@angular-devkit/build-webpack      0.901.5
@angular-devkit/core               9.1.5
@angular-devkit/schematics         9.1.5
@angular/cli                       9.1.5
@ngtools/webpack                   9.1.5
@schematics/angular                9.1.5
@schematics/update                 0.901.5
ng-packagr                         9.1.3
rxjs                               6.5.5
typescript                         3.8.3
webpack                            4.42.0

Anything else relevant?
Nope

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions