当我运行命令ts-node main.ts
时,我得到一个XMLHttpRequest没有定义Angular2,Typescript和NodeJS的错误。
这是我的例外
D:\workspace_git\nodejs\xgame\node_modules\@angular\platform-browser-dynamic\bundles\platform-browser-dynamic.umd.js:31
var xhr = new XMLHttpRequest();
^
ReferenceError: XMLHttpRequest is not defined
at ResourceLoaderImpl.get (D:\workspace_git\nodejs\xgame\node_modules\@angular\platform-browser-dynamic\bundles\platform-bro
wser-dynamic.umd.js:31:27)
at DirectiveNormalizer._fetch (D:\workspace_git\nodejs\xgame\node_modules\@angular\compiler\bundles\compiler.umd.js:13753:47
)
at DirectiveNormalizer.normalizeTemplateAsync (D:\workspace_git\nodejs\xgame\node_modules\@angular\compiler\bundles\compiler
.umd.js:13799:25)
at DirectiveNormalizer.normalizeTemplate (D:\workspace_git\nodejs\xgame\node_modules\@angular\compiler\bundles\compiler.umd.
js:13771:48)
at CompileMetadataResolver._loadDirectiveMetadata (D:\workspace_git\nodejs\xgame\node_modules\@angular\compiler\bundles\comp
iler.umd.js:18074:79)
at D:\workspace_git\nodejs\xgame\node_modules\@angular\compiler\bundles\compiler.umd.js:18250:58
at Array.forEach (native)
at CompileMetadataResolver.loadNgModuleDirectiveAndPipeMetadata (D:\workspace_git\nodejs\xgame\node_modules\@angular\compile
r\bundles\compiler.umd.js:18249:45)
at D:\workspace_git\nodejs\xgame\node_modules\@angular\compiler\bundles\compiler.umd.js:27366:62
at Array.forEach (native)
at JitCompiler._loadModules (D:\workspace_git\nodejs\xgame\node_modules\@angular\compiler\bundles\compiler.umd.js:27365:47)
at JitCompiler._compileModuleAndComponents (D:\workspace_git\nodejs\xgame\node_modules\@angular\compiler\bundles\compiler.um
d.js:27320:56)
at JitCompiler.compileModuleAsync (D:\workspace_git\nodejs\xgame\node_modules\@angular\compiler\bundles\compiler.umd.js:2728
6:25)
at PlatformRef_._bootstrapModuleWithZone (D:\workspace_git\nodejs\xgame\node_modules\@angular\core\bundles\core.umd.js:8083:
29)
at PlatformRef_.bootstrapModule (D:\workspace_git\nodejs\xgame\node_modules\@angular\core\bundles\core.umd.js:8058:25)
如何修复此错误。