angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

ng serve --aot fail after file change

Open WandererInVoids opened this issue 8 years ago • 67 comments

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 https://github.com/angular/angular/pull/25335. Reverting @angular/compiler to 6.1.1 workaround for this. I tested without fix, it work as before.

WandererInVoids avatar Aug 09 '18 18:08 WandererInVoids

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

dkchv avatar Aug 09 '18 20:08 dkchv

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

klemenoslaj avatar Aug 10 '18 06:08 klemenoslaj

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 https://github.com/NativeScript/nativescript-dev-webpack/issues/630.

vchimev avatar Aug 10 '18 08:08 vchimev

I have exactly the same problem with Angular CLI: 6.1.3

MichielDG avatar Aug 10 '18 12:08 MichielDG

Added to the top of our backlog

alexeagle avatar Aug 10 '18 16:08 alexeagle

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

clydin avatar Aug 10 '18 17:08 clydin

@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.

WandererInVoids avatar Aug 10 '18 17:08 WandererInVoids

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.

clydin avatar Aug 10 '18 18:08 clydin

@clydin can u try this https://github.com/angular/angular-cli/issues/11835#issuecomment-412009587, u changed file while server active?

WandererInVoids avatar Aug 10 '18 19:08 WandererInVoids

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

clydin avatar Aug 11 '18 01:08 clydin

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

alanxone avatar Aug 12 '18 13:08 alanxone

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

WandererInVoids avatar Aug 14 '18 20:08 WandererInVoids

For me this issue even with 6.1.1 (6.1.0 all was fine)

deerua avatar Aug 15 '18 16:08 deerua

@deerua Can you share your package.json to see if any conflicts?

alanxone avatar Aug 15 '18 16:08 alanxone

Sure


  "dependencies": {
    "@angular/animations": "^6.1.1",
    "@angular/cdk": "^6.4.1",
    "@angular/common": "^6.1.1",
    "@angular/compiler": "^6.1.1",
    "@angular/core": "^6.1.1",
    "@angular/forms": "^6.1.1",
    "@angular/http": "^6.1.1",
    "@angular/material": "^6.4.1",
    "@angular/platform-browser": "^6.1.1",
    "@angular/platform-browser-dynamic": "^6.1.1",
    "@angular/platform-server": "^6.1.1",
    "@angular/router": "^6.1.1",
    "@ngrx/core": "^1.2.0",
    "@ngrx/effects": "^6.0.1",
    "@ngrx/router-store": "^6.0.1",
    "@ngrx/store": "^6.0.1",
    "@ngrx/store-devtools": "^6.0.1",
    "@nguniversal/common": "6.0.0",
    "@nguniversal/express-engine": "6.0.0",
    "@nguniversal/module-map-ngfactory-loader": "6.0.0",
    "@ngx-translate/core": "10.0.2",
    "@ngx-translate/http-loader": "^3.0.1",
    "@types/angular": "1.6.45",
    "@types/cheerio": "^0.22.7",
    "@types/compression": "0.0.36",
    "@types/googlemaps": "^3.30.8",
    "angular-calendar": "0.25.1",
    "cheerio": "^1.0.0-rc.2",
    "compression": "^1.7.2",
    "core-js": "2.5.1",
    "cross-env": "https://registry.npmjs.org/cross-env/-/cross-env-5.1.4.tgz",
    "date-fns": "1.29.0",
    "express-winston": "latest",
    "hammerjs": "2.0.8",
    "immer": "^1.5.0",
    "jasmine-console-reporter": "^3.0.2",
    "karma-failed-reporter": "0.0.3",
    "localize-router": "https://github.com/manzonif/temp-localize-router/archive/a45b7b3f1eebfe82e3093e0b6cd5bb00612e9bb6.tar.gz",
    "mobile-detect": "1.4.1",
    "ngrx-store-localstorage": "5.0.1",
    "ngx-lazy-load-images": "^1.3.1",
    "ngx-translate-parser-plural-select": "1.1.3",
    "preboot": "6.0.0-beta.4",
    "request": "^2.83.0",
    "rxjs": "^6.2.2",
    "rxjs-tslint": "^0.1.5",
    "ts-action": "^6.0.2",
    "ts-action-operators": "^7.0.0",
    "ts-loader": "^4.4.2",
    "ts-md5": "^1.2.4",
    "winston": "^2.4.0",
    "zone.js": "^0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.7.3",
    "@angular/cli": "^6.1.1",
    "@angular/compiler-cli": "^6.1.1",
    "@angular/flex-layout": "^6.0.0-beta.17",
    "@angular/language-service": "^6.1.1",
    "@compodoc/compodoc": "1.1.3",
    "@ngrx/schematics": "^6.0.1",
    "@storybook/addon-notes": "4.0.0-alpha.14",
    "@storybook/addon-options": "4.0.0-alpha.14",
    "@storybook/addon-viewport": "4.0.0-alpha.14",
    "@storybook/addons": "4.0.0-alpha.14",
    "@storybook/angular": "4.0.0-alpha.14",
    "@types/express": "^4.11.1",
    "@types/express-winston": "^2.4.0",
    "@types/hammerjs": "2.0.34",
    "@types/jasmine": "2.5.38",
    "@types/lodash": "^4.14.95",
    "@types/node": "6.0.60",
    "@types/request": "^2.47.0",
    "@types/storybook__addon-notes": "^3.3.1",
    "angular-playground": "1.7.1",
    "babel-core": "^6.26.0",
    "codelyzer": "4.2.1",
    "concurrently": "^3.5.1",
    "enhanced-resolve": "3.3.0",
    "jasmine-core": "2.5.2",
    "jasmine-marbles": "^0.3.1",
    "jasmine-spec-reporter": "3.2.0",
    "karma": "1.7.1",
    "karma-chrome-launcher": "2.2.0",
    "karma-cli": "1.0.1",
    "karma-coverage-istanbul-reporter": "1.3.0",
    "karma-jasmine": "1.1.0",
    "karma-jasmine-html-reporter": "0.2.2",
    "karma-verbose-reporter": "0.0.6",
    "localstorage-polyfill": "^1.0.1",
    "node-pre-gyp": "0.6.39",
    "node-sass": "4.9.2",
    "rxjs-compat": "^6.2.2",
    "rxjs-tslint-rules": "^3.9.0",
    "sass-lint": "1.12.1",
    "source-map-explorer": "1.5.0",
    "ts-node": "4.1.0",
    "tslint": "5.9.1",
    "tslint-eslint-rules": "4.1.1",
    "typescript": "^2.9.0",
    "webpack-bundle-analyzer": "2.9.1",
    "webpack-cli": "^3.0.8"
  },

deerua avatar Aug 15 '18 16:08 deerua

After some changes we have 183 ERRORS Most of it

Module not found: Error: Can't resolve '@angular/router.ngfactory' 

and all material components

deerua avatar Aug 15 '18 16:08 deerua

^6.1.1 means install the latest version of 6.x (with a minimum of 6.1.1) which would be 6.1.2

As a temporary workaround, you can fix @angular/compiler to 6.1.1 (note you will receive peer dependency warnings). You can also stay on Angular 6.1.1 as a whole until a fix is available. Also when building for production, moving to consistent versions would be advised (i.e., all 6.1.1 or all 6.1.2).

Note also that CLI and @angular-devkit/build-angular can be at their latest version.

clydin avatar Aug 15 '18 16:08 clydin

thx @clydin i have checked node_modules manually before and all the deps. was 6.1.1 :) in package.json, strange but after strict version all become fine (looks like)

deerua avatar Aug 15 '18 17:08 deerua

The same issue after update to 6.1.2. Downgrade to 6.1.1 helped

Stantmn avatar Aug 15 '18 20:08 Stantmn

Been fighting with this for about a week now. I can confirm this package.json fixes all issues (made with npm i -g @angular/[email protected] then manually edited):

{
  "name": "admin",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve --aot",
    "build": "ng build --aot --prod"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "6.1.1",
    "@angular/common": "6.1.1",
    "@angular/compiler": "6.1.1",
    "@angular/core": "6.1.1",
    "@angular/forms": "6.1.1",
    "@angular/http": "6.1.1",
    "@angular/platform-browser": "6.1.1",
    "@angular/platform-browser-dynamic": "6.1.1",
    "@angular/router": "6.1.1",
    "core-js": "^2.5.4",
    "rxjs": "^6.0.0",
    "zone.js": "~0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "0.7.0",
    "@angular/cli": "6.1.1",
    "@angular/compiler-cli": "6.1.1",
    "@angular/language-service": "6.1.1",
    "@types/node": "~8.9.4",
    "ts-node": "~5.0.1",
    "tslint": "~5.9.1",
    "typescript": "~2.7.2"
  }
}

darkguy2008 avatar Aug 16 '18 00:08 darkguy2008