Angular8 在使用服务端渲染,启动项目时报错,__metadata(“design:paramtypes”, [Event]),ReferenceError: Event is not defined 启动命令npm run serve:ssr
> blog-web@0.0.0 serve:ssr G:\boboJavaProjects\boboJavaBlog\blogWeb
> node dist/server
G:\boboJavaProjects\boboJavaBlog\blogWeb\dist\server\main.js:73880
__metadata("design:paramtypes", [Event]),
^
ReferenceError: Event is not defined
at G:\boboJavaProjects\boboJavaBlog\blogWeb\dist\server\main.js:73880:46
at G:\boboJavaProjects\boboJavaBlog\blogWeb\dist\server\main.js:73884:6
at LUXU (G:\boboJavaProjects\boboJavaBlog\blogWeb\dist\server\main.js:73424:13)
at Object.LUXU (G:\boboJavaProjects\boboJavaBlog\blogWeb\dist\server\main.js:73426:2)
at __webpack_require__ (G:\boboJavaProjects\boboJavaBlog\blogWeb\dist\server\main.js:20:30)
at Module.K011 (G:\boboJavaProjects\boboJavaBlog\blogWeb\dist\server\main.js:72456:31)
at __webpack_require__ (G:\boboJavaProjects\boboJavaBlog\blogWeb\dist\server\main.js:20:30)
at Object.0 (G:\boboJavaProjects\boboJavaBlog\blogWeb\dist\server\main.js:885:18)
at __webpack_require__ (G:\boboJavaProjects\boboJavaBlog\blogWeb\dist\server\main.js:20:30)
at G:\boboJavaProjects\boboJavaBlog\blogWeb\dist\server\main.js:84:18
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! blog-web@0.0.0 serve:ssr: `node dist/server`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the blog-web@0.0.0 serve:ssr 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! G:\Software\nodejs\node_cache\_logs\2019-10-17T12_16_43_536Z-debug.log
解决办法
server.ts里面添加如下代码
global['Event'] = null;