当我在 Asp 核心中使用 Angular2 WebPack 时:处理请求时发生未处理的异常

When I Use Angular2 WebPack in Asp Core : An unhandled exception occurrs while processing the request

我在 Asp Core 中使用 Angular2 WebPack。

我正在使用此模板:Template

我删除了:Home , Counter , Fetch Data ( HTML , Ts ),也删除了app.module中的导入

import { NgModule } from '@angular/core';
import { UniversalModule } from 'angular2-universal';
import { AppComponent } from './components/app/app.component'
import { NavMenuComponent } from './components/navmenu/navmenu.component';

@NgModule({
    bootstrap: [ AppComponent ],
    declarations: [
        AppComponent,
        NavMenuComponent
    ]
})
export class AppModule {
}

现在当我 运行 项目时,它显示以下错误:

An unhandled exception occurred while processing the request.

Exception: Call to Node module failed with error: Error: No ErrorHandler. Is platform module (BrowserModule) included? at E:\MyProject\Angular2Application6\Angular2Application6\node_modules\@angular\core\bundles\core.umd.js:6921:27 at ZoneDelegate.invoke (E:\MyProject\Angular2Application6\Angular2Application6\node_modules\zone.js\dist\zone-node.js:232:26) at Object.onInvoke (E:\MyProject\Angular2Application6\Angular2Application6\node_modules\@angular\core\bundles\core.umd.js:6242:41) at ZoneDelegate.invoke (E:\MyProject\Angular2Application6\Angular2Application6\node_modules\zone.js\dist\zone-node.js:231:32) at Zone.run (E:\MyProject\Angular2Application6\Angular2Application6\node_modules\zone.js\dist\zone-node.js:114:43) at NgZoneImpl.runInner (E:\MyProject\Angular2Application6\Angular2Application6\node_modules\@angular\core\bundles\core.umd.js:6269:75) at NgZone.run (E:\MyProject\Angular2Application6\Angular2Application6\node_modules\@angular\core\bundles\core.umd.js:6499:70) at PlatformRef_._bootstrapModuleFactoryWithZone (E:\MyProject\Angular2Application6\Angular2Application6\node_modules\@angular\core\bundles\core.umd.js:6916:27) at PlatformRef_.bootstrapModuleFactory (E:\MyProject\Angular2Application6\Angular2Application6\node_modules\@angular\core\bundles\core.umd.js:6904:25) at E:\MyProject\Angular2Application6\Angular2Application6\node_modules\angular2-platform-node\node-platform.js:439:38

有什么问题吗?我该如何解决?

我认为缺少模块 BrowserModule,您可以尝试使用以下方式添加模块:

import { BrowserModule } from '@angular/platform-browser';

@NgModule({
    imports: [
        BrowserModule
    ]
    bootstrap: [ AppComponent ],
    declarations: [
        AppComponent,
        NavMenuComponent
    ]
 })
   export class AppModule {
}

如果错误没有解决也许你可以检查你是否使用angular 2 RC4 将发布版本更新为RC5,因为NgModule 是在Angular 2 RC5 中引入的.