如何解决如何在Angular --prod版本中修复“ TypeError:未定义不是构造函数评估'new Lt.Subject'”?与--optimization = false一起使用
Angular应用程序在开发人员模式下甚至在--prod --optimization=false
上也运行良好,但是当我使用--prod --optimization=true
进行构建时(我猜默认情况下优化是正确的),出现以下错误。
关于在哪里查找错误或如何调试此错误的任何想法?如果有帮助,我还会在下面粘贴我的package.json依赖项。
[Error] ERROR
Error: Uncaught (in promise): TypeError: undefined is not a constructor (evaluating 'new Lt.Subject') t@https://xxx.info/beta/app/main.a7aa466b736f5543d287.js:1:2258798 https://xxx.info/beta/app/main.a7aa466b736f5543d287.js:1:2259766 pr@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:166340 fr@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:165313 https://xxx.info/beta/app/main.a7aa466b736f5543d287.js:1:4983103 pr@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:166340 https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:230109 Os@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:230170 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:304618 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:201118 value@https://xxx.info/beta/app/main.a7aa466b736f5543d287.js:1:1469275 value@https://xxx.info/beta/app/main.a7aa466b736f5543d287.js:1:1421987 https://xxx.info/beta/app/main.a7aa466b736f5543d287.js:1:1420976 forEach@[native code] value@https://xxx.info/beta/app/main.a7aa466b736f5543d287.js:1:1420946 value@https://xxx.info/beta/app/main.a7aa466b736f5543d287.js:1:1419636 https://xxx.info/beta/app/main.a7aa466b736f5543d287.js:1:1454212 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:393084 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:101984 value@https://xxx.info/beta/app/main.a7aa466b736f5543d287.js:1:1510529 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:101984 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:393182 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:101984 value@https://xxx.info/beta/app/main.a7aa466b736f5543d287.js:1:807039 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:438224 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:101984 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:393182 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:101984 https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:393796 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:109038 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:108825 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:108694 value@https://xxx.info/beta/app/main.a7aa466b736f5543d287.js:1:806530 value@https://xxx.info/beta/app/main.a7aa466b736f5543d287.js:1:806359 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:101984 value@https://xxx.info/beta/app/main.a7aa466b736f5543d287.js:1:807039 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:438224 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:101984 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:393182 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:101984 value@https://xxx.info/beta/app/main.a7aa466b736f5543d287.js:1:1510529 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:101984 value@https://xxx.info/beta/app/main.a7aa466b736f5543d287.js:1:807039 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:438224 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:101984 value@https://xxx.info/beta/app/main.a7aa466b736f5543d287.js:1:1510529 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:101984 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:99363 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:438224 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:101984 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:99363 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:438224 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:101984 https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:393796 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:109038 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:108825 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:99137 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:99031 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:98851 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:101984 value@https://xxx.info/beta/app/main.a7aa466b736f5543d287.js:1:334008 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:102156 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:102156 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:99282 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:102156 https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:393813 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:109038 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:108825 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:108694 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:108694 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:108694 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:108694 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:99137 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:99031 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:98851 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:101984 https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:393796 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:109038 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:108825 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:108694 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:108694 value@https://xxx.info/beta/app/main.a7aa466b736f5543d287.js:1:806530 value@https://xxx.info/beta/app/main.a7aa466b736f5543d287.js:1:806359 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:101984 value@https://xxx.info/beta/app/main.a7aa466b736f5543d287.js:1:1510529 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:101984 https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:393796 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:109038 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:108825 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:108694 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:108694 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:108694 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:108694 value@https://xxx.info/beta/app/main.a7aa466b736f5543d287.js:1:806530 value@https://xxx.info/beta/app/main.a7aa466b736f5543d287.js:1:806359 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:101984 value@https://xxx.info/beta/app/main.a7aa466b736f5543d287.js:1:1317286 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:101984 value@https://xxx.info/beta/app/main.a7aa466b736f5543d287.js:1:1510529 value@https://xxx.info/beta/app/styles.f0239b81073897b8f4c1.js:1:101984
w — polyfills.e2119ff0d0c4c3dc72e3.js:1:14646
w — polyfills.e2119ff0d0c4c3dc72e3.js:1:14165
(tuntematon funktio) — polyfills.e2119ff0d0c4c3dc72e3.js:1:15437
onInvokeTask — styles.f0239b81073897b8f4c1.js:1:336076
(tuntematon funktio) — polyfills.e2119ff0d0c4c3dc72e3.js:1:4143
y — polyfills.e2119ff0d0c4c3dc72e3.js:1:11377
(tuntematon funktio) — polyfills.e2119ff0d0c4c3dc72e3.js:1:10216
g — polyfills.e2119ff0d0c4c3dc72e3.js:1:23267
m — polyfills.e2119ff0d0c4c3dc72e3.js:1:23568
Or (styles.f0239b81073897b8f4c1.js:1:167955)
value (styles.f0239b81073897b8f4c1.js:1:168198)
next (styles.f0239b81073897b8f4c1.js:1:343905)
(tuntematon funktio) (styles.f0239b81073897b8f4c1.js:1:310767)
value (styles.f0239b81073897b8f4c1.js:1:104327)
value (styles.f0239b81073897b8f4c1.js:1:103474)
value (styles.f0239b81073897b8f4c1.js:1:102354)
value (styles.f0239b81073897b8f4c1.js:1:101985)
value (styles.f0239b81073897b8f4c1.js:1:115827)
value (styles.f0239b81073897b8f4c1.js:1:310544)
(tuntematon funktio) (polyfills.e2119ff0d0c4c3dc72e3.js:1:3476)
onHandleError (styles.f0239b81073897b8f4c1.js:1:336479)
(tuntematon funktio) (polyfills.e2119ff0d0c4c3dc72e3.js:1:3694)
t (polyfills.e2119ff0d0c4c3dc72e3.js:1:13295)
(tuntematon funktio) (polyfills.e2119ff0d0c4c3dc72e3.js:1:13443)
y (polyfills.e2119ff0d0c4c3dc72e3.js:1:11444)
(tuntematon funktio) (polyfills.e2119ff0d0c4c3dc72e3.js:1:10216)
g (polyfills.e2119ff0d0c4c3dc72e3.js:1:23267)
m (polyfills.e2119ff0d0c4c3dc72e3.js:1:23568)
package.json依赖项:
"dependencies": {
"@angular/animations": "11.0.0-rc.0","@angular/cdk": "^10.2.7","@angular/common": "11.0.0-rc.0","@angular/compiler": "11.0.0-rc.0","@angular/core": "11.0.0-rc.0","@angular/forms": "11.0.0-rc.0","@angular/http": "7.2.14","@angular/material": "^10.2.7","@angular/platform-browser": "11.0.0-rc.0","@angular/platform-browser-dynamic": "11.0.0-rc.0","@angular/platform-server": "^11.0.0-rc.1","@angular/router": "11.0.0-rc.0","@ng-bootstrap/ng-bootstrap": "^4.2.2","@types/smoothscroll-polyfill": "^0.3.1","ajv": "^6.12.6","angular-2-local-storage": "^2.0.1","angular-fittext": "^2.1.1","angular-froala-wysiwyg": "^2.9.8","angular2-lightbox": "^1.4.1","angular2-loaders-css": "^2.0.1","angular2-tooltips": "^1.0.10","bootstrap": "^4.5.3","classlist.js": "^1.1.20150312","core-js": "^2.6.11","dom-to-image": "^2.6.0","fsevents": "^2.1.3","hammer-timejs": "^1.1.0","hammerjs": "^2.0.8","lightbox2": "^2.11.3","mammoth": "^1.4.13","md-tooltip": "0.0.1-alpha.1","ng2-component-spinner": "^0.2.1","ng2-dnd": "^5.0.2","ng2-file-upload": "^1.4.0","ng2-scroll-to-el": "^1.2.1","ngx-bootstrap": "^1.9.1","ngx-contextmenu": "^5.4.0","ngx-pipes": "^2.7.5","ngx-quill": "^12.0.1","ngx-sortablejs": "^10.0.0","ngx-spinner": "^7.2.0","npm": "^7.0.7","popper": "^1.0.0","popper.js": "^1.16.1","quill": "^1.3.7","quill-image-uploader": "^1.2.2","raf": "^3.4.1","rxjs": "^6.6.3","rxjs-compat": "^6.6.3","smoothscroll-polyfill": "^0.4.4","sortablejs": "^1.12.0","tether": "^1.4.7","web-animations-js": "^2.3.2","webfontloader": "^1.6.28","zone.js": "^0.10.3"
},"devDependencies": {
"@angular-devkit/build-angular": "^0.1002.0","@angular-devkit/build-optimizer": "^0.1002.0","@angular/cli": "^10.2.0","@angular/compiler-cli": "^11.0.0-rc.1","@types/jasmine": "2.5.38","@types/node": "^6.14.13","@types/sortablejs": "^1.10.6","codelyzer": "^4.5.0","jasmine-core": "~2.5.2","jasmine-spec-reporter": "~3.2.0","karma": "^5.2.3","karma-chrome-launcher": "~2.0.0","karma-cli": "~1.0.1","karma-coverage-istanbul-reporter": "^0.2.0","karma-jasmine": "^1.1.2","karma-jasmine-html-reporter": "^0.2.2","node-sass": "^4.14.1","protractor": "^7.0.0","raw-loader": "^0.5.1","sass-loader": "^6.0.7","source-map-explorer": "^1.8.0","ts-node": "~2.0.0","tslint": "^5.20.1","typescript": "^4.0.3","webpack-bundle-analyzer": "^3.9.0"
}
不幸的是,没有优化的构建是不可行的,因为它产生的文件很大。
解决方法
看来此问题可能是由于许多原因造成的。为了帮助调试此类问题,它有助于删除加扰的变量和类名称以查看实际名称。
为此,您可以在生产模式下在本地运行应用程序,而无需通过以下操作来处理变量名:
env NG_BUILD_MANGLE=false NG_BUILD_MINIFY=false NG_BUILD_BEAUTIFY=true ng serve --prod
通过这种方式,更容易查看在哪里进行了错误的呼叫。
在这种情况下,导致错误的原因是我使用Import Subject from 'rxjs/Subject'
从rxjs导入了Subject-看来现在应该用Import Subject from 'rxjs'
代替这种导入。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。