-
Notifications
You must be signed in to change notification settings - Fork 12k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[1.5.0-beta.3] AOT build failed - Module not found (Can't resolve './app.ngfactory') #7925
Comments
Heya, are you using Angular 4 or 5? Are there other errors shown before that? That error usually comes up when the application fails to compile at all. I can take a look if you provide a repro. |
@filipesilva For me, this error occurred simply upgrading from Angular 4 to 5, without changing any other dependencies. |
@jinder it's a generic error really. It's lengthy but just really means that AOT compilation failed. Either way, I can't reproduce it in a new project... there's more to the problem. If someone can provide a reproduction it would help. |
@filipesilva I'll investigate more on my side. Was hoping it'd be easy to nail down, but it's on a massive project and the error message isn't terribly informative! |
You sure there isn't any other error message before or after this one? Also, what version of the CLI are you using? |
@filipesilva I'm on Angular 5.0.0-rc.0 as I mentioned in the issue and I too just upgraded the cli from version 1.4.x to 1.5.0-beta.3 and this error occurred. This happened on a quite large project but the only error message I got was the one I provided. I can't test it with the latest cli right now but once I have the opportunity I'll look into it again. |
@filipesilva no other error. It was CLI 1.5.0-beta 3. I've got some big deliverables to ship by end of next week, but if nobody's solved it by then I'll start stripping things out to see if I can pinpoint the error. Is there any way to get some more info from the error description? |
@filipesilva Think I've figured it out through a process of elimination. It's caused by the the fact that the 'index.ts' bootstrap file was importing the app module via a barrel. So, changing this:
to:
Fixed it. Weirdly this is only a problem with Angular 5 (did not happen in Angular 4). @MrBlaise Does this fix it for you? |
Thanks @jinder importing the module directly resolved the issue for me. @filipesilva you can repro by simply adding an
and in It results in the error above, key point is that it is trying to find the module at a path like this (not the lack of module/folder path added):
To note: I only updated the AppModule import as per @jinder suggestions and everything compiled. I left all other module imports as coming from their "barrel" and had no issues |
@jinder Sorry for the late response, I was away for a week. Your workaround did indeed solve my problem as well, thanks! (Works with the latest rc.0 version as well with Angular 5.0.0-rc.0) I am having weird errors with the latest Angular version, but that is probably another issue EDIT: It was a problem on my end, so everything works with latest cli and angular |
@jinder @jmcgoldrick thanks for the repro, that tells me exactly what's going on. It has to do with how we automatically refactor code to load AOT factories in |
I'm not sure if we can manage to actually fix it though, because we need the real path to |
@filipesilva Was a pretty easy fix once found. Could suffice to have a more informative error message. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Bug Report or Feature Request (mark with an
x
)Versions.
angular-cli: 1.5.0-beta.3
Repro steps.
Upgraded angular-cli from 1.4.4 to 1.5.0-beta.3 and tried to build it with
ng build --prod --aot --build-optimizer
Using version 1.4.4 everything works.
The log given by the failure.
Desired functionality.
AOT build should work.
Mention any other details that might be useful.
Angular 5.0.0-rc.0
yarn 1.1.0
Windows 10
node v8.1.4
The text was updated successfully, but these errors were encountered: