TrilonIO / aspnetcore-angular-universal

ASP.NET Core & Angular Universal advanced starter - PWA w/ server-side rendering for SEO, Bootstrap, i18n internationalization, TypeScript, unit testing, WebAPI REST setup, SignalR, Swagger docs, and more! By @TrilonIO
https://www.trilon.io
MIT License
1.46k stars 433 forks source link

Event is not defined - webpack-internal #573

Open fadelguy opened 6 years ago

fadelguy commented 6 years ago

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+d__7.MoveNext()

Can someone please help me.

chrisvfabio commented 6 years ago

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!

Flood commented 6 years ago

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

chrisvfabio commented 6 years ago

Which package is causing the issue?

Flood commented 6 years ago

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 commented 6 years ago

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

natilivni commented 6 years ago

Any update on this?

MarkPieszak commented 6 years ago

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!

chrisvfabio commented 6 years ago

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?

vikerman commented 6 years ago

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