Skip to content

ng serve --aot fail after file change #11835

Closed

Description

@WandererInVoids

Bug Report or Feature Request (mark with an x)

- [X] bug report -> please search issues before submitting
- [ ] feature request

Command (mark with an x)

- [ ] new
- [ ] build
- [x] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Versions

Angular CLI: 6.1.2
Node: 10.0.0
OS: win32 x64
Angular: 6.1.2
... animations, cli, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, platform-server, router
... service-worker

Package Version

@angular-devkit/architect 0.7.2
@angular-devkit/build-angular 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.7.2
@angular/cdk 6.4.3
@angular/material 6.4.3
@ngtools/webpack 6.1.2
@schematics/angular 0.7.2
@schematics/update 0.7.2
rxjs 6.2.2
typescript 2.9.2
webpack 4.9.2
-->

Repro steps

  1. run ng serve with aot flag
  2. change something in watch filles
  3. see error in module find(file that change)

The log given by the failure

Module not found: Error: Can't resolve '@angular/material/button.ngfactory' in 'D:\Flare\flare.ui2\src\homeapp\app\components\reports\profitAndLoss'
ERROR in ./src/homeapp/app/components/reports/profitAndLoss/profit.and.loss.ngfactory.js
Module not found: Error: Can't resolve '@angular/material/checkbox.ngfactory' in 'D:\Flare\flare.ui2\src\homeapp\app\components\reports\profitAndLoss'
ERROR in ./src/homeapp/app/components/reports/profitAndLoss/profit.and.loss.ngfactory.js
Module not found: Error: Can't resolve '@angular/material/form-field.ngfactory' in '.\src\homeapp\app\components\reports\profitAndLoss'
ERROR in ./src/homeapp/app/components/reports/profitAndLoss/profit.and.loss.ngfactory.js
Module not found: Error: Can't resolve '@angular/material/menu.ngfactory' in '.\src\homeapp\app\components\reports\profitAndLoss'

Date: 2018-08-09T17:57:03.581Z - Hash: 12b8572033feade48d1a - Time: 34472ms
4 unchanged chunks
chunk {main} main.js (main) 16.2 MB [initial] [rendered]

i 「wdm」: Failed to compile.

Desired functionality

work as before update

Mention any other details that might be useful

I didn't know where to write, in @angular/compile or here but error showed in cli, so...
This breaking from this fix angular/angular#25335.
Reverting @angular/compiler to 6.1.1 workaround for this.
I tested without fix, it work as before.

Activity

  1. dkchv commented on Aug 9, 2018

    @dkchv

    the same, v6.1.2 is broken.
    downgrade to
    "@angular/compiler-cli": "6.1.1",

  2. klemenoslaj commented on Aug 10, 2018

    @klemenoslaj

    I have exactly the same problem, and reverting @angular/compiler "fixes" the problem.

  3. vchimev commented on Aug 10, 2018

    @vchimev

    Hey,

    This issue can also reproduce as follows:

    Steps:

    ng new ngApp --routing && cd ngApp
    ng serve --aot
    change a file under watch

    Error:

    ERROR in ./src/app/app.module.ngfactory.js
    Module not found: Error: Can't resolve '@angular/router.ngfactory' in '/Users/vchimev/Work/tmp/ngApp/src/app'
    ℹ 「wdm」: Failed to compile.
    

    Causes NativeScript/nativescript-dev-webpack#630.

  4. MichielDG commented on Aug 10, 2018

    @MichielDG

    I have exactly the same problem with Angular CLI: 6.1.3

  5. alexeagle commented on Aug 10, 2018

    @alexeagle
    Contributor

    Added to the top of our backlog

  6. added this to the needsTriage milestone on Aug 10, 2018
  7. clydin commented on Aug 10, 2018

    @clydin
    Member

    I was unable to replicate this with the following versions. Can you try with the versions listed below? For existing projects, please ensure that @angular-devkit/build-angular is updated; upgrading the CLI does not automatically update @angular-devkit/build-angular.

    Angular CLI: 6.1.3
    Node: 8.9.4
    OS: darwin x64
    Angular: 6.1.2
    ... animations, common, compiler, compiler-cli, core, forms
    ... http, language-service, platform-browser
    ... platform-browser-dynamic, router
    
    Package                           Version
    -----------------------------------------------------------
    @angular-devkit/architect         0.7.3
    @angular-devkit/build-angular     0.7.3
    @angular-devkit/build-optimizer   0.7.3
    @angular-devkit/build-webpack     0.7.3
    @angular-devkit/core              0.7.3
    @angular-devkit/schematics        0.7.3
    @angular/cli                      6.1.3
    @ngtools/webpack                  6.1.3
    @schematics/angular               0.7.3
    @schematics/update                0.7.3
    rxjs                              6.2.2
    typescript                        2.7.2
    webpack                           4.9.2
    
  8. WandererInVoids commented on Aug 10, 2018

    @WandererInVoids
    Author

    @clydin i used this:

    Angular CLI: 6.1.3
    Node: 10.8.0
    OS: win32 x64(windows 10)
    Angular: 6.1.2
    ... animations, common, compiler, compiler-cli, core, forms
    ... http, language-service, platform-browser
    ... platform-browser-dynamic, platform-server, router
    ... service-worker
    
    Package                           Version
    -----------------------------------------------------------
    @angular-devkit/architect         0.7.3
    @angular-devkit/build-angular     0.7.3
    @angular-devkit/build-optimizer   0.7.3
    @angular-devkit/build-webpack     0.7.3
    @angular-devkit/core              0.7.3
    @angular-devkit/schematics        0.7.3
    @angular/cdk                      6.4.3
    @angular/cli                      6.1.3
    @angular/material                 6.4.3
    @ngtools/webpack                  6.1.3
    @schematics/angular               0.7.3
    @schematics/update                0.7.3
    rxjs                              6.2.2
    typescript                        2.9.2
    webpack                           4.9.2
    

    also i used ng server without bazel,
    same error when updated.

    my tsconfig

    {
      "compilerOptions": {
        "baseUrl": "",
        "declaration": false,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "listEmittedFiles":true,
        "lib": ["es6", "dom", "es2016.array.include"],
        "mapRoot": "./",
        "module": "es6",
        "moduleResolution": "node",
        "outDir": "../dist/out-tsc",
        "sourceMap": false,
        "target": "es5",
        "alwaysStrict": true,
        "typeRoots": [
          "../node_modules/@types"
        ]
      },
      "angularCompilerOptions": {
        "preserveWhitespaces": false
      }
    }
    

    serve config

      "serve": {
              "builder": "@angular-devkit/build-angular:dev-server",
              "options": {
                "browserTarget": "homeapp:build"
              },
              "configurations": {
                "production": {
                  "browserTarget": "homeapp:build:production"
                }
              }
            },
    

    command : ng serve --aot --source-map=false
    it happen time to time just change file few times. U will see it.

  9. clydin commented on Aug 10, 2018

    @clydin
    Member

    As a test, every watched file in a new project was changed twice with both TS 2.7.2 and TS 2.9.2; and was unable to reproduce. Two files were also changed 5 times each (a component and a module) with the same outcome. To fully diagnose the issue, a minimal reproduction or exact steps to trigger the issue will be needed in light of the inability to reproduce.

  10. WandererInVoids commented on Aug 10, 2018

    @WandererInVoids
    Author

    @clydin can u try this #11835 (comment),
    u changed file while server active?

  11. clydin commented on Aug 11, 2018

    @clydin
    Member

    Thanks. Traced the issue to this PR in angular itself: angular/angular#25335
    This change was introduced within @angular/compiler in version 6.1.2.

  12. alanxone commented on Aug 12, 2018

    @alanxone

    Same issue confirmed, and the only solution for AOT so far is back to use 6.1.1

  13. WandererInVoids commented on Aug 14, 2018

    @WandererInVoids
    Author

    any progress?
    With this i can`t test angular 7 beta

  14. 51 remaining items

  15. artuska commented on Feb 20, 2019

    @artuska

    Issue still exists when ng build --aot.
    Issue still exists when ng serve --aot.

    Angular CLI: 7.3.2
    Node: 10.0.0
    OS: darwin x64
    Angular: 7.2.5
    ... animations, common, compiler, compiler-cli, core, forms
    ... http, language-service, platform-browser
    ... platform-browser-dynamic, router
    
    Package                           Version
    -----------------------------------------------------------
    @angular-devkit/architect         0.13.2
    @angular-devkit/build-angular     0.13.2
    @angular-devkit/build-optimizer   0.13.2
    @angular-devkit/build-webpack     0.13.2
    @angular-devkit/core              7.3.2
    @angular-devkit/schematics        7.3.2
    @angular/cli                      7.3.2
    @ngtools/webpack                  7.3.2
    @schematics/angular               7.3.2
    @schematics/update                0.13.2
    rxjs                              6.4.0
    typescript                        3.2.4
    webpack                           4.29.0
    
  16. JWBrownie commented on Feb 22, 2019

    @JWBrownie

    I have the same issue as @artuska with the same specs.

    Angular CLI: 7.3.3
    Node: 8.12.0
    OS: win32 x64
    Angular: 7.2.6
    ... animations, common, compiler, compiler-cli, core, forms
    ... http, language-service, platform-browser
    ... platform-browser-dynamic, router
    
    Package                           Version
    -----------------------------------------------------------
    @angular-devkit/architect         0.13.3
    @angular-devkit/build-angular     0.13.3
    @angular-devkit/build-optimizer   0.13.3
    @angular-devkit/build-webpack     0.13.3
    @angular-devkit/core              0.7.5
    @angular-devkit/schematics        0.7.5
    @angular/cdk                      7.3.3
    @angular/cli                      7.3.3
    @angular/flex-layout              7.0.0-beta.23
    @angular/material                 7.3.3
    @ngtools/json-schema              1.1.0
    @ngtools/webpack                  7.3.3
    @schematics/angular               7.3.3
    @schematics/update                0.13.3
    ng-packagr                        4.7.1
    rxjs                              6.4.0
    typescript                        3.2.4
    webpack                           4.29.0
  17. artuska commented on Feb 23, 2019

    @artuska

    @JWBrownie If you have this type of error probably you have upgraded from Angular 5 to 6 or 7.

    Replace "rootDir": "./src", in your tsconfig.json file to "rootDir": "./", or just remove this parameter completely.

  18. artuska commented on Feb 23, 2019

    @artuska

    See also #13721

  19. gatsbyz commented on Feb 27, 2019

    @gatsbyz

    @artuska VERIFIED. Worked for me. Thank you from NYC.

  20. andrewantar commented on Mar 18, 2019

    @andrewantar

    Still having this issue on Angular 7.2
    Only with ng build or serve --aot or --prod, I get: .ngfactory.js Module not found
    Any help? I see a 'fixed by Ivy' tag applied - would I have to wait for Ivy?

  21. gatsbyz commented on Mar 19, 2019

    @gatsbyz

    @andrewantar try removing optimization flags in angular.json

  22. andrewantar commented on Mar 19, 2019

    @andrewantar

    @gatsbyz Set them to false and also tried removing the params, and still same error..

  23. gatsbyz commented on Mar 19, 2019

    @gatsbyz

    @andrewantar And you've tried removing this from your tsconfig.json -> "rootDir": "./src"

  24. snatuva commented on Apr 19, 2019

    @snatuva

    If your tsconfig.json has this path. remove and try it. It worked for me.

    "paths": { "@angular/*": ["../node_modules/@angular/*"] },

  25. alvaroarandaj commented on Jun 17, 2019

    @alvaroarandaj

    If your tsconfig.json has this path. remove and try it. It worked for me.

    "paths": { "@angular/*": ["../node_modules/@angular/*"] },

    It works like black magic mate!!!!!!!

  26. bishwa-poudel commented on Jul 27, 2019

    @bishwa-poudel

    I am still getting error in Angular 7.2.15 while building using --aot flag. Normal build is working fine.
    The error message looks like:

    ERROR in src\app\Test.component.html(6,8): : Property 'sort' does not exist on type 'TestComponent'.
    
    src\app\Test.component.html(3,74): : Property 'allowUnsort' does not exist on type 'TestComponent'.
    
    

    It is not recognizing any of the kendo grid properties. My kendo grid html looks like this:

    <kendo-grid #grid [kendoGridBinding]="gridData | async" [pageSize]="10" [pageable]="true" [filterable]="true"
      [groupable]="true" [resizable]="true" [reorderable]="true" [filterable]="true" [columnMenu]="true"
      [rowClass]="rowCallback" (dataStateChange)="onDataStateChange($event)" [sortable]="{
        allowUnsort: allowUnsort,
        mode: multiple ? 'multiple' : 'single'
        }" [sort]="sort" (sortChange)="sortChange($event)">
    
  27. angular-automatic-lock-bot commented on Sep 9, 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.

  28. locked and limited conversation to collaborators on Sep 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions