Solvedangular Can't resolve *.ngfactory.js on AOT serve after update to Angular 6.1
✔️Accepted Answer
I am having the same issue. I had the issue with angular cli 6.0.8 and also after a upgrade to 6.1.3 . First of all I thought it was because I changed the project structure a bit from what angular cli generated. But then I just tried it out with an new empty angular cli project and I got the same error.
Steps to reproduce:
- Create a new project using ng new (I used following command:
ng new poc --style=scss --minimal --routing
) - Go to the folder
- Start angular with
ng serve --aot
- Change a file, for example app.component.ts by adding a new line or similar and save.
I get following error as result
ERROR in ./src/app/app.module.ngfactory.js
Module not found: Error: Can't resolve '@angular/router.ngfactory' in 'C:\dev\private-tools\hive-platform\poc2\src\app'
Don't know if it is important, but I am using yarn as package manager for node.
Other Answers:
Can confirm this error (the @angular/router.ngfactory one). Interestingly it only appears on the second incremental rebuild, so the initial dev build works, first src file save works, saving the file again ... BOOM.
Workaround: downgrade and hard code all @angular/* packages (excluding cli, that one does not matter) to 6.1.1 (no ~ or ^), the bug was most likely introduced in 6.1.2 (#25335).
Comes only with the second or consecutive incremental builds
@toverux's workaround worked for me as well. Pin angular compiler and compiler-cli to 6.1.1.
$ npm i -S @angular/compiler@6.1.1 @angular/compiler-cli@6.1.1
I'm submitting a...
Current behavior
After updating to angular 6.1.3 with
ng update
when I serve my project with AOT (i need it) everything works fine but after a refresh (after a save for example) i get a lot of errors like that :And crash
Expected behavior
That should not append just like before
Minimal reproduction of the problem with instructions
ng serve --aot
ERROR in ./src/app/app.module.ngfactory.js Module not found: Error: Can't resolve '@angular/router.ngfactory' in '/mnt/d/Sites/test-app/src/app'
What is the motivation / use case for changing the behavior?
Angular become unusable after that
Environment