在某些情况下会导致某些错误,例如使用localStorage
或window
对象。但是,只有在打开浏览器并抛出localhost:8080
时才会发生这些错误,更具体地说,您将转到使用这些对象的特定路径。然后,我们可以通过导入isPlatformBrowser
来处理它。
但是在我的情况下,发生在我运行节点服务器时,它失败了。我安装了ng-zorro模块。它将模块导入了broswer.module
文件中。另外,我将模块导入到我的延迟加载模块中并使用了它的组件。但是当我运行server.js时,出现以下错误:
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
为什么我在此级别上遇到这些错误?