angular – EXCEPTION:TypeError:无法设置undefined的属性’message’

前端之家收集整理的这篇文章主要介绍了angular – EXCEPTION:TypeError:无法设置undefined的属性’message’前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
在旧的角度2项目上升级了许多依赖项后,我在运行时遇到以下错误

EXCEPTION: TypeError: Cannot set property 'message' of undefined
ErrorHandler.handleError @ error_handler.js:50
(anonymous) @ application_ref.js:259
ZoneDelegate.invoke @ zone.js:242
onInvoke @ ng_zone.js:269
ZoneDelegate.invoke @ zone.js:241
Zone.run @ zone.js:113
(anonymous) @ zone.js:520
ZoneDelegate.invokeTask @ zone.js:275
onInvokeTask @ ng_zone.js:260
ZoneDelegate.invokeTask @ zone.js:274
Zone.runTask @ zone.js:151
drainMicroTaskQueue @ zone.js:418
zone.js:405Unhandled Promise rejection: TypeError: Cannot set property 'message' of undefined
    at ViewWrappedError.set [as message] (errors.js:43)
    at ViewWrappedError.ZoneAwareError (zone.js:683)
    at ViewWrappedError.BaseError [as constructor] (errors.js:26)
    at ViewWrappedError.WrappedError [as constructor] (errors.js:88)
    at new ViewWrappedError (errors.js:73)
    at CompiledTemplate.proxyViewClass.DebugAppView._rethrowWithContext (view.js:650)
    at CompiledTemplate.proxyViewClass.DebugAppView.create (view.js:550)
    at CompiledTemplate.proxyViewClass.View_AppComponent0.createInternal (component.ngfactory.js:125)
    at CompiledTemplate.proxyViewClass.AppView.create (view.js:95)
    at CompiledTemplate.proxyViewClass.DebugAppView.create (view.js:547)
    at CompiledTemplate.proxyViewClass.View_AppComponent_Host0.createInternal (host.ngfactory.js:26)
    at CompiledTemplate.proxyViewClass.AppView.createHostView (view.js:108)
    at CompiledTemplate.proxyViewClass.DebugAppView.createHostView (view.js:564)
    at ComponentFactory.create (component_factory.js:226)
    at ApplicationRef_.bootstrap (application_ref.js:586) ; Zone: <root> ; Task: Promise.then ; Value: TypeError: Cannot set property 'message' of undefined
    at ViewWrappedError.set [as message] (errors.js:43)
    at ViewWrappedError.ZoneAwareError (zone.js:683)
    at ViewWrappedError.BaseError [as constructor] (errors.js:26)
    at ViewWrappedError.WrappedError [as constructor] (errors.js:88)
    at new ViewWrappedError (errors.js:73)
    at CompiledTemplate.proxyViewClass.DebugAppView._rethrowWithContext (view.js:650)
    at CompiledTemplate.proxyViewClass.DebugAppView.create (view.js:550)
    at CompiledTemplate.proxyViewClass.View_AppComponent0.createInternal (component.ngfactory.js:125)
    at CompiledTemplate.proxyViewClass.AppView.create (view.js:95)
    at CompiledTemplate.proxyViewClass.DebugAppView.create (view.js:547)
    at CompiledTemplate.proxyViewClass.View_AppComponent_Host0.createInternal (host.ngfactory.js:26)
    at CompiledTemplate.proxyViewClass.AppView.createHostView (view.js:108)
    at CompiledTemplate.proxyViewClass.DebugAppView.createHostView (view.js:564)
    at ComponentFactory.create (component_factory.js:226)
    at ApplicationRef_.bootstrap (application_ref.js:586) undefined
consoleError @ zone.js:405
_loop_1 @ zone.js:434
drainMicroTaskQueue @ zone.js:438
zone.js:407ZoneAwareError {message: "Uncaught (in promise): TypeError: Cannot set prope…p (http://localhost:4200/main.bundle.js:47366:57)",originalStack: "Error: Uncaught (in promise): TypeError: Cannot se… (http://localhost:4200/main.bundle.js:130849:35)",zoneAwareStack: "Error: Uncaught (in promise): TypeError: Cannot se…localhost:4200/main.bundle.js:130849:35) [<root>]",stack: "Error: Uncaught (in promise): TypeError: Cannot se…localhost:4200/main.bundle.js:130849:35) [<root>]",rejection: TypeError: Cannot set property 'message' of undefined
    at ViewWrappedError.set [as message] (http……}

我试图搜索我的所有应用程序(包含大约20个组件)的.message,并且发现我使用this.message属性的结果很少,我确定问题不在那里.

我试图逐个删除几乎所有的模块和组件,但无法找到解决方法.

我的package.json:

{
  "name": "myapp","version": "0.0.0","license": "MIT","angular-cli": {},"scripts": {
    "start": "ng serve","lint": "tslint \"src/**/*.ts\"","test": "ng test","pree2e": "webdriver-manager update","e2e": "protractor"
  },"private": true,"dependencies": {
    "@angular/common": "2.2.1","@angular/compiler": "2.2.1","@angular/core": "2.2.1","@angular/forms": "2.2.1","@angular/http": "2.2.1","@angular/material": "^2.0.0-alpha.11-3","@angular/platform-browser": "2.2.1","@angular/platform-browser-dynamic": "2.2.1","@angular/router": "3.2.3","@ng-bootstrap/ng-bootstrap": "^1.0.0-alpha.15","@types/hammerjs": "^2.0.32","angular2-moment": "^1.0.0","angular2-notifications": "^0.4.47","core-js": "^2.4.1","dragula": "^3.7.1","hammerjs": "^2.0.8","ng2-bootstrap": "^1.1.16-7","ng2-dnd": "^2.0.1","ng2-dragula": "^1.2.0","ng2-select": "^1.1.2","rxjs": "5.0.0-rc.4","ts-helpers": "^1.1.1","zone.js": "^0.7.2"
  },"devDependencies": {
    "@angular/compiler-cli": "2.2.1","@types/jasmine": "2.5.38","@types/node": "^6.0.42","angular-cli": "1.0.0-beta.20-4","codelyzer": "~2.0.0-beta.1","jasmine-core": "2.5.2","jasmine-spec-reporter": "2.5.0","karma": "1.2.0","karma-chrome-launcher": "^2.0.0","karma-cli": "^1.0.1","karma-jasmine": "^1.0.2","karma-remap-istanbul": "^0.2.1","protractor": "4.0.9","ts-node": "1.2.1","tslint": "^4.0.2","typescript": "~2.0.3","webdriver-manager": "10.2.5"
  }
}

任何人都知道如何更有效地找到这个错误的来源?

解决方法

这是zone.js包的问题,​​它阻止控制台显示实际错误
尝试降级zone.js:

npm install --save zone.js@0.7.4

猜你在找的Angularjs相关文章