Angular-cli: ng add - please specify a project name

Created on 25 May 2018  Â·  1Comment  Â·  Source: angular/angular-cli

Versions

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / â–³ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 6.0.5
Node: 10.1.0
OS: darwin x64
Angular: 6.0.3
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.6.5
@angular-devkit/build-angular      0.6.5
@angular-devkit/build-ng-packagr   0.6.5
@angular-devkit/build-optimizer    0.6.5
@angular-devkit/core               0.6.5
@angular-devkit/schematics         0.6.5
@angular/cli                       6.0.5
@angular/material                  6.1.0
@ngtools/json-schema               1.1.0
@ngtools/webpack                   6.0.5
@schematics/angular                0.6.5
@schematics/update                 0.6.5
ng-packagr                         3.0.0-rc.5
rxjs                               6.2.0
typescript                         2.7.2
webpack                            4.8.3

Repro steps

  • Step 1
    starting a new project with ng new angular-project
  • Step 2
    generate a library/application inside the new angular-cli project
    sh ng g library mylibrary ng g application myapp
  • Step 3
    Add @angular/material
    ng add @angular/material myapp Installing packages for tooling via npm. Multiple projects are defined; please specify a project name

Observed behavior

@angular/material gets correclty installed in the node dependencies but the myapp project is not configured for using the library.

Desired behavior

The current ng add usage is: usage: ng add <collection>
Ideally this should allow passing the target app like this:

usage: ng add <collection> [options]
options:
  --project
      The name of the project.
angulacli feature

Most helpful comment

I was trying to do the same. If you do ng add @angular/material --project=my-app it "works". What I observed was:

  1. The docs don't specify this parameter.
  2. ng generate @angular/material:material-nav --name=app-nav scaffolds the component on the src\app instead of generating on the default project. You also need to append --project=my-app to set to its correct location.
  3. ng serve --project=demo will serve the correct app
  4. The generated template has a little bug isHandset$ | async needs to be wrapped in ()

>All comments

I was trying to do the same. If you do ng add @angular/material --project=my-app it "works". What I observed was:

  1. The docs don't specify this parameter.
  2. ng generate @angular/material:material-nav --name=app-nav scaffolds the component on the src\app instead of generating on the default project. You also need to append --project=my-app to set to its correct location.
  3. ng serve --project=demo will serve the correct app
  4. The generated template has a little bug isHandset$ | async needs to be wrapped in ()
Was this page helpful?
0 / 5 - 0 ratings