如何在Angular --prod版本中修复“ TypeError:未定义不是构造函数评估'new Lt.Subject'”?与--optimization = false一起使用

如何解决如何在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 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 <select id="xxx"> SELECT di.id, di.name, di.work_type, di.updated... <where> <if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 <property name="dynamic.classpath" value="tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams['font.sans-serif'] = ['SimHei'] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -> systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping("/hires") public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate<String
使用vite构建项目报错 C:\Users\ychen\work>npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-