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

is the problem fixed in @angular/[email protected]?

alexfung888 avatar Aug 16 '18 08:08 alexfung888

It wasn't fixed in 6.1.3. I just checked it.

Stantmn avatar Aug 16 '18 18:08 Stantmn

Still not fixed with 6.1.4 right?

mackelito avatar Aug 17 '18 13:08 mackelito

This problem wasn't fixed in 6.1.4 I have this in @angular/cli >= 6.1.0

nasserghiasi avatar Aug 18 '18 11:08 nasserghiasi

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 RouterModule to src/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.

filipesilva avatar Aug 21 '18 11:08 filipesilva

i'm experiencing this same problem with 6.1.0

elmartino avatar Aug 22 '18 10:08 elmartino

@elmartino This is weird, please share your package.json.

alanxone avatar Aug 22 '18 10:08 alanxone

@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

alanxone avatar Aug 22 '18 10:08 alanxone

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!

elmartino avatar Aug 22 '18 10:08 elmartino

@filipesilva Would it be possible to cover this with integration tests in the future, given that it is very easy to reproduce?

benelliott avatar Aug 26 '18 18:08 benelliott

This appears to be fixed by the Angular 6.1.6 release today.

pshields avatar Aug 30 '18 01:08 pshields

I confirm that this issued is fixed in Angular v6.1.6.

sarunint avatar Aug 30 '18 04:08 sarunint

When will be the NPM release?

ns-rickvdmeij avatar Aug 30 '18 06:08 ns-rickvdmeij

@rickvandermeij-aanzee yesterday.

sarunint avatar Aug 30 '18 06:08 sarunint

didn't notice the fix is at @angular/compiler-cli

ns-rickvdmeij avatar Aug 30 '18 06:08 ns-rickvdmeij

@rickvandermeij-aanzee because it's in angular, not cli.

victornoel avatar Aug 30 '18 06:08 victornoel

Fixed via https://github.com/angular/angular/pull/25604, released in @angular/[email protected].

filipesilva avatar Aug 30 '18 09:08 filipesilva

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?

rabbit-will-run avatar Sep 06 '18 13:09 rabbit-will-run

@jgf5013 nope, since 6.1.6 everything works fine for me.

thegnuu avatar Sep 06 '18 13:09 thegnuu

@jgf5013 make sure that you have the latest versions specified, then delete node_modules folder and do an npm install.

AlQuraian avatar Sep 06 '18 13:09 AlQuraian