Skip to content

Build with --watch flag does not work with a lib project #11100

Closed

Description

@zbarbuto

Versions

Angular CLI: 6.0.7
Node: 9.6.1
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/cdk                       6.1.0
@angular/cli                       6.0.7
@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.7
ng-packagr                         3.0.0
rxjs                               6.2.0
typescript                         2.7.2
webpack                            4.8.3

Observed behavior

Running ng build --watch works perfectly fine on the default app in a monorepo with the default app.

However, running ng build mylib --watch or ng build --watch mylib after generating a lib with the CLI gives Unknown option: '--watch'

Desired behavior

Can build any of the apps or libs in an Angular cli monorepo in --watch mode.

Mention any other details that might be useful (optional)

Have tried various combinations of ordering the arguments as well as --watch=true and -w. None seem to work.

Activity

  1. elclanrs commented on Jun 4, 2018

    @elclanrs

    This is not supported yet. I'm eagerly awaiting for this PR to be merged in ng-packagr.

  2. gabrielalan commented on Jun 11, 2018

    @gabrielalan

    So they launch a new major version of the CLI breaking one of the commands? 😂

  3. added
    feature
    on Jun 11, 2018
  4. jrista commented on Jul 25, 2018

    @jrista

    Any idea on when this might be available? We are doing a lot of work with libs at the moment, no ability to watch is really rough...

  5. alan-agius4 commented on Jul 25, 2018

    @alan-agius4
    Collaborator
  6. added a commit that references this issue on Jul 30, 2018
    50fc721
  7. bezysoftware commented on Aug 2, 2018

    @bezysoftware

    I installed the latest 6.2.0 beta.0, but am still unable to do ng build --watch for a library ("unknown switch"). Here's outcome of ng --version:

    Angular CLI: 6.2.0-beta.0
    Node: 8.11.3
    OS: win32 x64
    Angular: 6.1.0
    ... common, compiler, compiler-cli, core, platform-browser
    ... platform-browser-dynamic, router
    
    Package                            Version
    ------------------------------------------------------------
    @angular-devkit/architect          0.7.2
    @angular-devkit/build-angular      0.7.2
    @angular-devkit/build-ng-packagr   0.7.2
    @angular-devkit/build-optimizer    0.7.2
    @angular-devkit/build-webpack      0.7.2
    @angular-devkit/core               0.7.2
    @angular-devkit/schematics         0.8.0-beta.0 (cli-only)
    @ngtools/json-schema               1.1.0
    @ngtools/webpack                   6.1.2
    @schematics/angular                0.8.0-beta.0 (cli-only)
    @schematics/update                 0.8.0-beta.0 (cli-only)
    ng-packagr                         4.0.1
    rxjs                               6.2.2
    typescript                         2.9.2
    webpack                            4.9.2
    

    Whats should I do?

  8. alan-agius4 commented on Aug 2, 2018

    @alan-agius4
    Collaborator

    @bezysoftware you need to update all @angular-devkit/<packages> to 0.8.0-beta.0

  9. bezysoftware commented on Aug 2, 2018

    @bezysoftware

    Thanks, that worked. Now first time compilation works, but the diff compilation fails:

    File change detected. Starting incremental compilation...
    
    BUILD ERROR
    no elements in sequence
    EmptyError: no elements in sequence
        at new EmptyError (C:\Users\**\projects\Nexus\WidgetMessaging\node_modules\rxjs\internal\util\EmptyError.js:16:28)
        at C:\Users\**\projects\Nexus\WidgetMessaging\node_modules\rxjs\internal\operators\last.js:11:294
        at Object.complete (C:\Users\**\projects\Nexus\WidgetMessaging\node_modules\rxjs\internal\operators\throwIfEmpty.js:12:23)
        at TapSubscriber._complete (C:\Users\**\projects\Nexus\WidgetMessaging\node_modules\rxjs\internal\operators\tap.js:76:31)
        at TapSubscriber.Subscriber.complete (C:\Users\**\projects\Nexus\WidgetMessaging\node_modules\rxjs\internal\Subscriber.js:76:18)
        at TakeLastSubscriber._complete (C:\Users\**\projects\Nexus\WidgetMessaging\node_modules\rxjs\internal\operators\takeLast.js:71:21)
        at TakeLastSubscriber.Subscriber.complete (C:\Users\**\projects\Nexus\WidgetMessaging\node_modules\rxjs\internal\Subscriber.js:76:18)
        at MergeMapSubscriber._complete (C:\Users\**\projects\Nexus\WidgetMessaging\node_modules\rxjs\internal\operators\mergeMap.js:80:30)
        at MergeMapSubscriber.Subscriber.complete (C:\Users\**\projects\Nexus\WidgetMessaging\node_modules\rxjs\internal\Subscriber.js:76:18)
        at FilterSubscriber.Subscriber._complete (C:\Users\**\projects\Nexus\WidgetMessaging\node_modules\rxjs\internal\Subscriber.js:94:26)
    
    
    Compilation failed. Watching for file changes...
    

    I guess tha'ts worth a separate issue

  10. alan-agius4 commented on Aug 2, 2018

    @alan-agius4
    Collaborator
  11. xino1010 commented on Aug 3, 2018

    @xino1010

    Hi @bezysoftware @alan-agius4 !
    How can I install the latest 6.2.0 beta.{0,1}?
    Thanks

  12. alan-agius4 commented on Aug 3, 2018

    @alan-agius4
    Collaborator

    You can use

    ng update @angular/cli --next
    
  13. GeorgeKnap commented on Aug 24, 2018

    @GeorgeKnap

    Watch mode works for these versions :)
    @angular-devkit at 0.8.0-rc.0
    @angular at 6.1.4
    ng-packagr at 4.1.0

    sweet!

  14. KoBe321 commented on Sep 13, 2018

    @KoBe321

    It's working for me with:

    @angular-devkit/build-angular": "^0.8.1
    @angular-devkit/build-ng-packagr": "^0.8.1
    @angular/cli": "^6.2.1
    ng-packagr": "^4.1.1
    

    However, if I make any changes in the lib, it reloads the page twice.

  15. arm1n commented on Sep 17, 2018

    @arm1n

    Although it's working for --watch now, it seems that no one of the other flags are working though, f.e. --output-path or --delete-output-path when using with a library. Im using Angular CLI 6.2.2. Can anyone else confirm this?

  16. drizzt74 commented on Nov 6, 2018

    @drizzt74

    @arm1n I can confirm it for Angular CLI 7.0.4. Althought I didn't extensively check, it seems the only working flags are those few reported by the ng build --help command, not those described in documentation page: https://angular.io/cli/build
    NOTE: I'm referring to a lib project

  17. angular-automatic-lock-bot commented on Sep 8, 2019

    @angular-automatic-lock-bot

    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.

  18. locked and limited conversation to collaborators on Sep 8, 2019
  19. added a commit that references this issue on May 29, 2026
    7246f29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    devkit/build-angular:libraryfeaturestate: blocked

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions