aspnetcore-angular-universal
aspnetcore-angular-universal copied to clipboard
Event is not defined - webpack-internal
Hi,
I'm using the last template. I take an existing project that wrote not for angular universal and I did some change to match it ssr.
All works fine but now I'm getting an error:
An unhandled exception occurred while processing the request.
NodeInvocationException: Event is not defined ReferenceError: Event is not defined at DomEventsPlugin.patchEvent (webpack-internal:///18:3287:9) at new DomEventsPlugin (webpack-internal:///18:3277:15) at eval (ng:///AppModule/module.ngfactory.js:22:25) at _callFactory (webpack-internal:///0:11147:28) at _createProviderInstance$1 (webpack-internal:///0:11089:26) at resolveNgModuleDep (webpack-internal:///0:11071:17) at _createClass (webpack-internal:///0:11114:29) at _createProviderInstance$1 (webpack-internal:///0:11086:26) at resolveNgModuleDep (webpack-internal:///0:11071:17) at _createClass (webpack-internal:///0:11114:29)
Microsoft.AspNetCore.NodeServices.HostingModels.HttpNodeInstance+<InvokeExportAsync>d__7.MoveNext()
Can someone please help me.
This issue is being tracked here: https://github.com/angular/universal/issues/844
This might be a possible workaround: https://github.com/angular/universal/issues/844#issuecomment-346929471
I had this issue with ngx-uploader: https://github.com/bleenco/ngx-uploader/issues/308#issuecomment-352645351 I forked the repo and added the fixes.
Hope this helps!
I have the same issue. I think there is a problem in angular/platform-browser.
Which package is causing the issue?
I have no idea. Yesterday I tried to remove/downgrade a lot of packages but it did not work. My webpack-internal:/// url points to platform-browser module. But there is a check for Event there so I don't know why it breaks there.
Angular team is investigating. https://github.com/angular/angular/issues/22902
Any update on this?
Take a look at this comment @natilivni https://github.com/angular/angular/issues/22902#issuecomment-387125291
Kudos to @chrisvfabio.
You can see in our default app.server.module
file here in the repo we have things in a specific order. https://github.com/MarkPieszak/aspnetcore-angular2-universal/blob/master/ClientApp/app/app.module.server.ts#L14-L20
imports: [
// Our Common AppModule
AppModuleShared,
// ServerModule (which does a lot of Dependency injection to make Universal "work")
ServerModule,
// Then NoopAnimationsModule which also does Dependency injection, to remove animations from occurring anywhere during SSRendering
NoopAnimationsModule
]
Also, make sure you only have HttpClientModule imported only once in app.module
Hope that helps guys!
Also, if you're using Angular 6, have a look at the universal demo from @vikerman https://github.com/vikerman/universal-shop/blob/master/level4/universal-shop/src/app/app.server.module.ts#L27
Note: For this template, you need to import AppModuleShared into app.module.server
I noticed that you don't need to import NoopAnimationsModule anymore in v6? Perhaps the BrowserAnimationsModule is platform-server compatible now?
I don't have any animations in that example yet. You still need NoopAnimationsModule. That hasn't changed in v6