首页 > 解决方案 > Angular 8 TypeError: Cannot add property 2, object is not extensible

问题描述

I have an Angular 8 app using RxJS and angular-cesium that is in production for the past 6 months, and I had no issues.

In the past week the app works fine when I run ng serve locally, but when I build it and deploy I am now getting this error when I make certain actions:

core.js.pre-build-optimizer.js:6014 ERROR TypeError: Cannot add property 2, object is not extensible
at Array.push (<anonymous>)
at l._subscribe (Subject.js.pre-build-optimizer.js:97)
at l._subscribe (BehaviorSubject.js.pre-build-optimizer.js:12)
at l._trySubscribe (Observable.js.pre-build-optimizer.js:42)
at l._trySubscribe (Subject.js.pre-build-optimizer.js:81)
at l.subscribe (Observable.js.pre-build-optimizer.js:28)
at je.call (app.component.ts:41)
at d.subscribe (Observable.js.pre-build-optimizer.js:23)
at IF.<anonymous> (lines-layer.component.ts:122)
at Generator.next (<anonymous>)

The start of the above stack trace (lines-layer.component.ts) changes every time I build, but the last 6 lines (starting from Observable.js) stay the same. I also get the same error when I serve the dist folder locally.

I've been debugging for a couple of days now and I've gotten nowhere... did anyone get this error too?

标签: angularrxjscesium

解决方案


我仍然不知道为什么会发生这种情况,但我(正确地)猜测它与我正在使用的某个库有关,所以我将它们全部更新到最新版本(包括 Angular 到版本 9)并且它成功了。


推荐阅读