如何使用webpack调试Angular 2?

时间:2017-01-17 19:59:37

标签: angular typescript webpack

鉴于以下错误:

EXCEPTION:Uncaught(在promise中):TypeError:无法设置只有getter的[object Object]的属性堆栈 TypeError:无法设置[object Object]的属性堆栈,它只有一个getter

我得到的堆栈跟踪是巨大的,我不知道哪个typescript文件是choking有一个只读属性。有没有办法告诉我它试图设置哪个属性只有一个吸气剂?

快速而肮脏的解决方案是逐个删除代码直到它工作。我能够分辨出它窒息的代码范围以及那里的问题。但是,如果从长远来看代码突然中断,那么他的解决方案并不理想,我不知道是什么打破了它而没有查看版本历史。

是否有工具可以帮助我解决这个问题?

Error: Uncaught (in promise): TypeError: Cannot set property stack of [object Object] which has only a getter TypeError: Cannot set property stack of [object Object] which has only a getter at assignAll (http://localhost:3000/polyfills.bundle.js:16015:29) at ViewWrappedError.ZoneAwareError (http://localhost:3000/polyfills.bundle.js:16086:16) at ViewWrappedError.BaseError [as constructor] (http://localhost:3000/main.bundle.js:5256:16) at ViewWrappedError.WrappedError [as constructor] (http://localhost:3000/main.bundle.js:5318:16) at new ViewWrappedError (http://localhost:3000/main.bundle.js:57044:16) at CompiledTemplate.proxyViewClass.DebugAppView._rethrowWithContext (http://localhost:3000/main.bundle.js:79673:23) at CompiledTemplate.proxyViewClass.DebugAppView.detectChanges (http://localhost:3000/main.bundle.js:79646:18) at CompiledTemplate.proxyViewClass.AppView.internalDetectChanges (http://localhost:3000/main.bundle.js:79433:18) at CompiledTemplate.proxyViewClass.View_ReportsComponent_Host0.detectChangesInternal (/ReportsModule/ReportsComponent/host.ngfactory.js:35:19) at CompiledTemplate.proxyViewClass.AppView.detectChanges (http://localhost:3000/main.bundle.js:79448:14) at CompiledTemplate.proxyViewClass.DebugAppView.detectChanges (http://localhost:3000/main.bundle.js:79643:44) at ViewRef_.detectChanges (http://localhost:3000/main.bundle.js:57990:20) at RouterOutlet.activate (http://localhost:3000/main.bundle.js:63236:42) at ActivateRoutes.placeComponentIntoOutlet (http://localhost:3000/main.bundle.js:21937:16) at ActivateRoutes.activateRoutes (http://localhost:3000/main.bundle.js:21904:26) at http://localhost:3000/main.bundle.js:21840:58 at Array.forEach (native) at ActivateRoutes.activateChildRoutes (http://localhost:3000/main.bundle.js:21840:29) at ActivateRoutes.activateRoutes (http://localhost:3000/main.bundle.js:21910:22) at http://localhost:3000/main.bundle.js:21840:58 at Array.forEach (native) at ActivateRoutes.activateChildRoutes (http://localhost:3000/main.bundle.js:21840:29) at ActivateRoutes.activate (http://localhost:3000/main.bundle.js:21814:14) at http://localhost:3000/main.bundle.js:21382:22 at SafeSubscriber._next (http://localhost:3000/main.bundle.js:4169:25) at SafeSubscriber.__tryOrUnsub (http://localhost:3000/main.bundle.js:6028:16) at SafeSubscriber.next (http://localhost:3000/main.bundle.js:5977:22) at Subscriber._next (http://localhost:3000/main.bundle.js:5930:26) at Subscriber.next (http://localhost:3000/main.bundle.js:5894:18) at MapSubscriber._next (http://localhost:3000/main.bundle.js:23024:26) at MapSubscriber.Subscriber.next (http://localhost:3000/main.bundle.js:5894:18) at MergeMapSubscriber.notifyNext (http://localhost:3000/main.bundle.js:22890:30) at InnerSubscriber._next (http://localhost:3000/main.bundle.js:85350:21) at InnerSubscriber.Subscriber.next (http://localhost:3000/main.bundle.js:5894:18) at MapSubscriber._next (http://localhost:3000/main.bundle.js:23024:26) at MapSubscriber.Subscriber.next (http://localhost:3000/main.bundle.js:5894:18) at ReduceSubscriber._complete (http://localhost:3000/main.bundle.js:86357:30) at ReduceSubscriber.Subscriber.complete (http://localhost:3000/main.bundle.js:5919:18) at MergeMapSubscriber._complete (http://localhost:3000/main.bundle.js:22882:30) at MergeMapSubscriber.Subscriber.complete (http://localhost:3000/main.bundle.js:5919:18) at ArrayObservable._subscribe (http://localhost:3000/main.bundle.js:66973:24) at ArrayObservable.Observable.subscribe (http://localhost:3000/main.bundle.js:4131:27) at MergeMapOperator.call (http://localhost:3000/main.bundle.js:22832:23) at Observable.subscribe (http://localhost:3000/main.bundle.js:4128:22) at ReduceOperator.call (http://localhost:3000/main.bundle.js:86316:23) at Observable.subscribe (http://localhost:3000/main.bundle.js:4128:22) at MapOperator.call (http://localhost:3000/main.bundle.js:22995:23) at Observable.subscribe (http://localhost:3000/main.bundle.js:4128:22) at Object.subscribeToResult (http://localhost:3000/main.bundle.js:46412:27) at MergeMapSubscriber._innerSub (http://localhost:3000/main.bundle.js:22877:38) at MergeMapSubscriber._tryNext (http://localhost:3000/main.bundle.js:22874:14) at MergeMapSubscriber._next (http://localhost:3000/main.bundle.js:22857:18) at MergeMapSubscriber.Subscriber.next (http://localhost:3000/main.bundle.js:5894:18) at MergeMapSubscriber.notifyNext (http://localhost:3000/main.bundle.js:22890:30) at InnerSubscriber._next (http://localhost:3000/main.bundle.js:85350:21) at InnerSubscriber.Subscriber.next (http://localhost:3000/main.bundle.js:5894:18) at MapSubscriber._next (http://localhost:3000/main.bundle.js:23024:26) at MapSubscriber.Subscriber.next (http://localhost:3000/main.bundle.js:5894:18) at EverySubscriber.notifyComplete (http://localhost:3000/main.bundle.js:67454:26) at EverySubscriber._complete (http://localhost:3000/main.bundle.js:67471:14) at EverySubscriber.Subscriber.complete (http://localhost:3000/main.bundle.js:5919:18) at MergeMapSubscriber._complete (http://localhost:3000/main.bundle.js:22882:30) at MergeMapSubscriber.Subscriber.complete (http://localhost:3000/main.bundle.js:5919:18) at ArrayObservable._subscribe (http://localhost:3000/main.bundle.js:66973:24) at ArrayObservable.Observable.subscribe (http://localhost:3000/main.bundle.js:4131:27) at MergeMapOperator.call (http://localhost:3000/main.bundle.js:22832:23) at Observable.subscribe (http://localhost:3000/main.bundle.js:4128:22) at EveryOperator.call (http://localhost:3000/main.bundle.js:67434:23) at Observable.subscribe (http://localhost:3000/main.bundle.js:4128:22) at MapOperator.call (http://localhost:3000/main.bundle.js:22995:23) at Observable.subscribe (http://localhost:3000/main.bundle.js:4128:22) at Object.subscribeToResult (http://localhost:3000/main.bundle.js:46412:27) at MergeMapSubscriber._innerSub (http://localhost:3000/main.bundle.js:22877:38) at MergeMapSubscriber._tryNext (http://localhost:3000/main.bundle.js:22874:14) at MergeMapSubscriber._next (http://localhost:3000/main.bundle.js:22857:18) at MergeMapSubscriber.Subscriber.next (http://localhost:3000/main.bundle.js:5894:18)

2 个答案:

答案 0 :(得分:3)

<强>更新

固定在 0.7.6

https://github.com/angular/zone.js/blob/master/CHANGELOG.md#076-2017-01-17

以前的版本

将zonejs降级为 0.7.4 https://github.com/angular/zone.js/issues/595

npm install --save zone.js@0.7.4

答案 1 :(得分:0)

原因是缺少库或模块。在您的某个模板中,您使用了应用程序未知的指令(已加载);

我是如何解决这个问题的。

  • 检查浏览器中的错误堆栈

  • 然后检查方法:例如CompiledTemplate.proxyViewClass Locals ==&GT;在那里,您可以看到一条有意义的错误消息,它会直接引导您找到丢失的指令

评论:此错误与&#34; zone.js&#34;;无关。如果更改&#34; zone.js&#34;可能会更改错误消息。版本