【问题标题】:How to debug Angular 2 with webpack?如何使用 webpack 调试 Angular 2?
【发布时间】:2017-01-17 19:59:37
【问题描述】:

鉴于以下错误:

异常:未捕获(承诺中):TypeError:无法设置只有 getter 的 [object Object] 的属性堆栈 TypeError:无法设置只有 getter 的 [object Object] 的属性堆栈

我得到的堆栈跟踪是巨大的,我不知道哪个打字稿文件具有只读属性。有没有办法告诉我它试图设置的属性只有一个 getter?

一个快速而肮脏的解决方案是一个接一个地删除代码,直到它工作为止。我将能够分辨出它阻塞的代码范围以及那里会出现什么问题。但是,如果从长远来看代码突然中断,那么他的这种解决方案并不理想,如果不查看版本历史,我将不知道是什么导致了它。

有什么工具可以帮助我解决这个问题吗?

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)

【问题讨论】:

    标签: angular typescript webpack


    【解决方案1】:

    更新

    它已在 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
    

    【讨论】:

    • 感谢您修复它。只是一个小问题,你知道为什么error_handler.js 会吐出一个巨大的错误跟踪吗?有办法限制吗?
    【解决方案2】:

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

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

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

    • 然后检查方法:例如CompiledTemplate.proxyViewClass 本地化 ==> 在那里你可以看到一个有意义的错误信息,它会直接引导你找到缺失的指令

    评论:此错误与“zone.js”无关;如果您更改“zone.js”版本,错误消息可能会更改

    【讨论】:

    • 其实和zone.js有关。我降级了我的版本,现在它至少给了我更好的错误信息。
    • 这就是我的意思。您收到不同的错误消息,但您的错误仍然存​​在。检查控制台中的错误堆栈以获取实际上是问题的错误消息
    猜你喜欢
    • 2017-01-13
    • 1970-01-01
    • 2017-11-12
    • 1970-01-01
    • 2017-07-28
    • 1970-01-01
    • 2017-04-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多