Angular2 Error - Is platform module (BrowserModule) included?

久未见 提交于 2019-12-01 03:34:16

问题


I'm just trying to run a simple index.html page in Angular2, but its showing me an error in zone.js in console:

    Unhandled Promise rejection: No ErrorHandler. Is platform module (BrowserModule) included? ; Zone: <root> ; Task: Promise.then ; Value: Error: No ErrorHandler. Is platform module (BrowserModule) included?
    at eval (application_ref.ts:364)
    at ZoneDelegate.invoke (zone.js:391)
    at Object.onInvoke (ng_zone.ts:296)
    at ZoneDelegate.invoke (zone.js:390)
    at Zone.run (zone.js:141)
    at NgZone.run (ng_zone.ts:153)
    at PlatformRef_._bootstrapModuleFactoryWithZone (application_ref.ts:359)
    at eval (application_ref.ts:330)
    at ZoneDelegate.invoke (zone.js:391)
    at Zone.run (zone.js:141) Error: No ErrorHandler. Is platform module (BrowserModule) included?
    at eval (http://localhost:3000/node_modules/@angular/core/bundles/core.umd.js:4531:23)
    at ZoneDelegate.invoke (http://localhost:3000/node_modules/zone.js/dist/zone.js:391:26)
    at Object.onInvoke (http://localhost:3000/node_modules/@angular/core/bundles/core.umd.js:3922:33)
    at ZoneDelegate.invoke (http://localhost:3000/node_modules/zone.js/dist/zone.js:390:32)
    at Zone.run (http://localhost:3000/node_modules/zone.js/dist/zone.js:141:43)
    at NgZone.run (http://localhost:3000/node_modules/@angular/core/bundles/core.umd.js:3853:69)
    at PlatformRef_._bootstrapModuleFactoryWithZone (http://localhost:3000/node_modules/@angular/core/bundles/core.umd.js:4526:23)
    at eval (http://localhost:3000/node_modules/@angular/core/bundles/core.umd.js:4568:59)
    at ZoneDelegate.invoke (http://localhost:3000/node_modules/zone.js/dist/zone.js:391:26)
    at Zone.run (http://localhost:3000/node_modules/zone.js/dist/zone.js:141:43)

Can someone help me basically what it is and how to fix this. Module File:

import {Component, NgModule} from "@angular/core";
import {App} from "./app";

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

}

回答1:


You are missing the

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

Add to your app module

@NgModule({
imports: [
    BrowserModule,
]
...})


来源:https://stackoverflow.com/questions/45256839/angular2-error-is-platform-module-browsermodule-included

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!