aspnetcore-angular-universal icon indicating copy to clipboard operation
aspnetcore-angular-universal copied to clipboard

Event is not defined - webpack-internal

Open fadelguy opened this issue 6 years ago • 9 comments

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.

fadelguy avatar Mar 21 '18 06:03 fadelguy

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!

chrisvfabio avatar Mar 21 '18 07:03 chrisvfabio

I have the same issue. I think there is a problem in angular/platform-browser.

Flood avatar Mar 21 '18 08:03 Flood

Which package is causing the issue?

chrisvfabio avatar Mar 21 '18 09:03 chrisvfabio

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.

Flood avatar Mar 21 '18 09:03 Flood

Angular team is investigating. https://github.com/angular/angular/issues/22902

Flood avatar Mar 21 '18 10:03 Flood

Any update on this?

natilivni avatar May 06 '18 13:05 natilivni

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!

MarkPieszak avatar May 07 '18 19:05 MarkPieszak

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?

chrisvfabio avatar May 08 '18 04:05 chrisvfabio

I don't have any animations in that example yet. You still need NoopAnimationsModule. That hasn't changed in v6

vikerman avatar May 08 '18 06:05 vikerman