angular: Ugraded to Angular 9: Error: Can't resolve all parameters for ApplicationModule: (?).
I upgraded my app to Angular 9 & am getting the following error:
Error: Can't resolve all parameters for ApplicationModule: (?).
at syntaxError (/home/brian/work/dishzilla/menus-angular-2-app/apps/angular-app/dist/server.js:7582:17)
at CompileMetadataResolver._getDependenciesMetadata (/home/brian/work/dishzilla/menus-angular-2-app/apps/angular-app/dist/server.js:27327:35)
at CompileMetadataResolver._getTypeMetadata (/home/brian/work/dishzilla/menus-angular-2-app/apps/angular-app/dist/server.js:27219:26)
at CompileMetadataResolver.getNgModuleMetadata (/home/brian/work/dishzilla/menus-angular-2-app/apps/angular-app/dist/server.js:27087:24)
at CompileMetadataResolver.getNgModuleSummary (/home/brian/work/dishzilla/menus-angular-2-app/apps/angular-app/dist/server.js:26889:35)
at /home/brian/work/dishzilla/menus-angular-2-app/apps/angular-app/dist/server.js:27008:51
at Array.forEach (<anonymous>)
at CompileMetadataResolver.getNgModuleMetadata (/home/brian/work/dishzilla/menus-angular-2-app/apps/angular-app/dist/server.js:26996:49)
at CompileMetadataResolver.getNgModuleSummary (/home/brian/work/dishzilla/menus-angular-2-app/apps/angular-app/dist/server.js:26889:35)
at /home/brian/work/dishzilla/menus-angular-2-app/apps/angular-app/dist/server.js:26981:55
I have spent hours debugging this issue, but still have not made progress. I’ve also seen a number of fixes for this error message in previous years but none of those solutions worked for me. Can you please advise on obtaining a better error message that is easier to debug, because this error message is not very helpful. Thank you
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 8
- Comments: 31 (8 by maintainers)
In my case (Angular 6 -> 6.1 LTS upgrade), it was because some idiot added
window.global = {window};
toindex.html
. Removing that cleared the error. Spent 4 hours trying to track this down. Angular sucks.@AndrewKushnir Unfortunately, I cannot provide a simple reproduction due to the complexity of the app. I added some logging statements & noticed that when
ReflectionCapabilities.prototype._ownParameters
is invoked on theApplicationModule
reflectiontype
, the logic falls through to theIf a class has no decorators, at least create metadata
case.[ undefined ]
is returned since the constructor has an arity of 1.https://github.com/angular/angular/blob/master/packages/core/src/reflection/reflection_capabilities.ts#L123
When
@angular/core/fesm5/core.js
is loaded. Here is the definition ofApplicationModule
in that file.I’m not familiar with how to access the source of the
ApplicationModule
type
object, as directly mutatingApplicationModule
does not seem carry over to thetype
object passed toReflectionCapabilities.prototype._ownParameters
.One thing I hope to get out of this issue is to identify the source of the problem & to have an error that directly notifies the programmer of the cause of the error.
I thought ivy was enabled by default on Angular 9. I admit that I don’t use Angular for most of my projects so I’m a bit out of the loop with the evolution of Angular & it’s various architectural updates. I’ll investigate if Ivy is being used…
@ericmartinezr I noticed that you gave a thumbs down on this issue. I’d love to provide more detail about the reproduction, but I’ve been spending > 6 hours trying to identify the issue. Is this not an area that can be improved or am I supposed to “suck it up” & pretend that everything is ok or something like that? I’d rather there be a quicker way to fix this problem without the need to file an issue in the first place. Since this same error has been reoccurring for years (since v2), with multi-hour debug sessions, is this not an area that can be improved to help developers?
@IamDeshRaj, you rock!
The root cause here is that
platformServer()
(andplatformBrowserDynamic
for that matter) expose a platform injector that providesCompilerFactory
withJitCompilerFactory
, which creates a View Engine compiler. Obviously that’s not going to work in an Ivy app!It turns out that
ngExpressEngine
relies onCompilerFactory
, which is why it shows up as an SSR bug.Once the application is created, it has a
Compiler
which is overridden in Ivy, which makes sense, but theCompilerFactory
at the platform level should also be overridden. It should be a pretty straightforward fix.Hi @btakita, @petebacondarwin, @alxhub @danielboggianosa, @AndrewKushnir… I have reproduced this error while trying to solve another issue, clone my repository and checkout branch app-module-error, and run commands 1. npm install and 2. npm run local:serverless URL like “http://localhost:3000/production” will flash on the console as shown in the snapshot below. Then I hope rest you will people will figure out, I’m really new to Angular and node, Struggling badly with both, this and another issue.
Thanks in advance.
Can you elaborate a little bit better like what changes in the app should be done? My use case is the same. I am using SSR with IVY. Angular version is 12.
This issue is still plaguing me any assistance would be greatly appreciated. Thanks everyone!
Tracking as FW-2197 internally.