ng serve --aot fail after file change
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
- run ng serve with aot flag
- change something in watch filles
- 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.
is the problem fixed in @angular/[email protected]?
It wasn't fixed in 6.1.3. I just checked it.
Still not fixed with 6.1.4 right?
This problem wasn't fixed in 6.1.4 I have this in @angular/cli >= 6.1.0
We're looking at this issue at the moment.
Steps to reproduce:
- create a new project
ng new repro-proj - make sure you're using at least
@angular/[email protected]or above - add
RouterModuletosrc/app/app.module.ts:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { AppComponent } from './app.component';
import { environment } from '../environments/environment';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
RouterModule,
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
- run
ng serve --aot - save
src/app/app.module.ts(no change in it needed) - see the following error:
ERROR in ./src/app/app.module.ngfactory.js
Module not found: Error: Can't resolve '@angular/router.ngfactory' in 'D:\sandbox\latest-project\src\app'
This problem seems to have been introduced in https://github.com/angular/angular/pull/25335, and is the same as reported in https://github.com/angular/angular/issues/25424.
I inspected the contents of src/app/app.module.ngfactory.js and what happens is that in the initial build it contains this import:
import * as i3 from "../../node_modules/@angular/router/router.ngfactory";
but in the rebuild the import is changed to
import * as i3 from "@angular/router.ngfactory";
I checked if the same happens happens with just ngc, and it doesn't.
Still investigating further.
i'm experiencing this same problem with 6.1.0
@elmartino
This is weird, please share your package.json.
@elmartino
I see, it seems you are no using exactly 6.1.0, please follow the instruction at https://github.com/angular/angular-cli/issues/11835#issuecomment-413262460
Had some trouble with the JSON markup, but you saw it already :-) changing "@angular/compiler": "^6.1.0", to "@angular/compiler": "6.1.0", working now. Thanks!
@filipesilva Would it be possible to cover this with integration tests in the future, given that it is very easy to reproduce?
This appears to be fixed by the Angular 6.1.6 release today.
I confirm that this issued is fixed in Angular v6.1.6.
When will be the NPM release?
@rickvandermeij-aanzee yesterday.
didn't notice the fix is at @angular/compiler-cli
@rickvandermeij-aanzee because it's in angular, not cli.
Fixed via https://github.com/angular/angular/pull/25604, released in @angular/[email protected].
I'm still getting this issue on both @6.1.0 and @6.1.6. Both @angular/compiler and @angular/compiler-cli were set to those versions. Is anyone else still experiencing this?
@jgf5013 nope, since 6.1.6 everything works fine for me.
@jgf5013 make sure that you have the latest versions specified, then delete node_modules folder and do an npm install.