TypeError:无法读取null的属性'getGlobalEventTarget'

时间:2018-04-24 09:43:26

标签: node.js angular npm npm-install

我正在将项目角度版本从4.4.7升级到最新版本。我将node.js更新为最新版本(8.11.1),并将angular cli更新为最新版本(1.7.4)。现在,当我使用npm start运行我的代码时,这是完整的错误。

core.es5.js:1020 ERROR Error: Uncaught (in promise): TypeError: 
Cannot read property 'getGlobalEventTarget' of null
TypeError: Cannot read property 'getGlobalEventTarget' of null
at DomEventsPlugin.EventManagerPlugin.addGlobalEventListener 
(platform-browser.es5.js:2474)
    at EventManager.addGlobalEventListener (platform-browser.es5.js:2405)
    at DefaultDomRenderer2.listen (platform-browser.es5.js:2912)
    at BaseAnimationRenderer.listen (animations.es5.js:491)
    at listenToElementOutputs (core.es5.js:9215)
    at createViewNodes (core.es5.js:12159)
    at createRootView (core.es5.js:12082)
    at Object.createProdRootView [as createRootView] (core.es5.js:12756)
    at ComponentFactory_.create (core.es5.js:9861)
    at ComponentFactoryBoundToModule.create (core.es5.js:3333)
    at DomEventsPlugin.EventManagerPlugin.addGlobalEventListener (platform-browser.es5.js:2474)
    at EventManager.addGlobalEventListener (platform-browser.es5.js:2405)
    at DefaultDomRenderer2.listen (platform-browser.es5.js:2912)
    at BaseAnimationRenderer.listen (animations.es5.js:491)
    at listenToElementOutputs (core.es5.js:9215)
    at createViewNodes (core.es5.js:12159)
    at createRootView (core.es5.js:12082)
    at Object.createProdRootView [as createRootView] (core.es5.js:12756)
    at ComponentFactory_.create (core.es5.js:9861)
    at ComponentFactoryBoundToModule.create (core.es5.js:3333)
    at resolvePromise (zone.js:814)
    at resolvePromise (zone.js:771)
    at zone.js:873
    at ZoneDelegate.invokeTask (zone.js:421)
    at Object.onInvokeTask (core.es5.js:3881)
    at ZoneDelegate.invokeTask (zone.js:420)
    at Zone.runTask (zone.js:188)
    at drainMicroTaskQueue (zone.js:595)
    at ZoneTask.invokeTask [as invoke] (zone.js:500)
    at invokeTask (zone.js:1540)

1 个答案:

答案 0 :(得分:0)

删除从子模块导入的角度BrowserModule,BrowserAnimationsModule / NoopAnimationsModule。 并将这些导入内容包含在“父模块”中,您就很好了。

//import { BrowserModule }  from '@angular/platform-browser';
//import { BrowserAnimationsModule, NoopAnimationsModule } from '@angular/platform-browser/animations';
@NgModule({
  declarations: [..],
  imports: [
    CommonModule,
    //BrowserModule,
    //BrowserAnimationsModule,
    //NoopAnimationsModule,
  ],
  providers: [],
})
export class ChildModule { }