0

There are usual cases that cause some errors like using localStorage or window object. But these errors happen only when you open the browser and go throw the localhost:8080 and more specifically, you go to a specific route that you use those objects. Then we can handle it by importing isPlatformBrowser.

But in my case, it happens when I run my node server, it fails. I installed ng-zorro module. It imported the module in broswer.module file. Also, I imported the module in my lazy loaded module and used it's component. But when I run the server.js, I get the following 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

Why I get these errors in this level?

Vahid Najafi
  • 4,654
  • 11
  • 43
  • 88

0 Answers0