question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

importing the main module causes errors while using Angular Universal

See original GitHub issue

Reproduction link

https://stackblitz.com/edit/ng-zorro-antd-start-sm4bvm?file=src/app/app.component.ts

Steps to reproduce

Just simply install the module with ng add and import it in a module (lazy loaded) and run it by server. Everything is working fine without server side rendering.

What is expected?

It’s expected at least to run without error and if it’s not compatible with Angular Universal, we can handle it with *ngIf="isBrowser".

What is actually happening?

I’m getting these errors:

C:\Users\vahidnajafi\repos\project\dist\server.js:186704
        Object(tslib_es6["__metadata"])("design:paramtypes", [Event]),
                                                              ^

ReferenceError: Event is not defined
    at C:\Users\vahidnajafi\repos\project\dist\server.js:186704:63
    at Module.<anonymous> (C:\Users\vahidnajafi\repos\project\dist\server.js:186708:2)
    at __webpack_require__ (C:\Users\vahidnajafi\repos\project\dist\server.js:21:30)
    at Object.ng-zorro-antd (C:\Users\vahidnajafi\repos\project\dist\server.js:166774:18)
    at __webpack_require__ (C:\Users\vahidnajafi\repos\project\dist\server.js:161065:30)
    at Object../node_modules/ng-zorro-antd/ng-zorro-antd.ngfactory.js (C:\Users\vahidnajafi\repos\project\dist\server.js:161224:31)
    at __webpack_require__ (C:\Users\vahidnajafi\repos\project\dist\server.js:161065:30)
    at Object../src/app/modules/sazframework/sazframework.module.ngfactory.js (C:\Users\vahidnajafi\repos\project\dist\server.js:165959:31)
    at __webpack_require__ (C:\Users\vahidnajafi\repos\project\dist\server.js:161065:30)
    at Object../src/main.server.ts (C:\Users\vahidnajafi\repos\project\dist\server.js:166456:39)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! project@0.0.0 server: `node local.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the project@0.0.0 server script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\vahidnajafi\AppData\Roaming\npm-cache\_logs\2019-04-04T17_19_42_062Z-debug.log

Environment Info
ng-zorro-antd 7.2.0
Browser Chrome

Sorry about the demo link. This is not reproducible due to the error in server side rendering.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:14 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
vthinkxiecommented, Jun 16, 2019

@mapsgeek our doc site is built with static render with SSR, if you meet any problem, plz submit a new issue with repro link.

0reactions
mapsgeekcommented, Jun 17, 2019

@vahidvdn https://ng.ant.design/docs/universal/en here it’s pretty much what you have done by adding the global['event']=null but i don’t know why it didn’t work when i tried your suggestion but then worked when i replaced my server.ts content with the one on the docs page here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular import module error - Stack Overflow
1. you have to import the Material module · All the material design modules are imported on app. · import the SharedModule in...
Read more >
Angular Universal: real app problems - InDepth.Dev
This article will discuss the issues and possible solutions we encountered while developing a real application with Angular Universal and Express.
Read more >
Why your Angular App is not Working: 11 common Mistakes
Only import the modules you really need! Importing unnecessarily module bloats your application size significantly.
Read more >
Singleton services - Angular
There are two ways to make a service a singleton in Angular: ... Use forRoot() to separate providers from a module so you...
Read more >
Angular Modules and NgModule - Complete Guide
Let's now try to use in our root module, by importing it: ... This was the main reason why lazy loading in AngularJs...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found