在 ng build --prod 之后,为什么我在 main.js:1 和 polyfills.js:1 中出现错误,而不是在我创建的组件中出现错误,如何撤消?

问题描述

我想部署一个几乎完成的 Angular 项目,并且为了部署我执行了 ng build --prod。它创建了一个比我部署到服务器的 dist。到这里都明白了,但现在当我更改项目中的内容并执行“ng serve -o”时,我没有看到我在编写这些 console.log 消息的那些组件中设置的控制台消息,而是引用了这些消息来自“main.js:1”和“polyfills.js:1”。

我仍然收到这些控制台消息,但我不知道它是在控制台上的哪个组件中打印出来的。

ERROR TypeError: Cannot read property 'UserzAccessStatus' of undefined
    at main.js:1
    at i.<computed> (polyfills.js:1)
    at e.invokeTask (polyfills.js:1)
    at Object.onInvokeTask (main.js:1)
    at e.invokeTask (polyfills.js:1)
    at t.runTask (polyfills.js:1)
    at t.invokeTask (polyfills.js:1)
    at invoke (polyfills.js:1)
    at r.args.<computed> (polyfills.js:1)

Chrome 控制台中的 Console.log() 消息

enter image description here

package.json 文件

{
  "name": "gbcl","version": "0.0.0","scripts": {
    "ng": "ng","start": "ng serve","build": "ng build","test": "ng test","lint": "ng lint","e2e": "ng e2e","start:server": "nodemon server.js"
  },"private": true,"dependencies": {
    "@angular/animations": "~12.0.0","@angular/common": "~12.0.0","@angular/compiler": "~12.0.0","@angular/core": "~12.0.0","@angular/forms": "~12.0.0","@angular/platform-browser": "~12.0.0","@angular/platform-browser-dynamic": "~12.0.0","@angular/router": "~12.0.0","bcrypt": "^5.0.1","body-parser": "^1.19.0","bootstrap": "^4.5.2","express": "^4.17.1","jquery": "^3.6.0","mongoose": "^5.12.8","mongoose-unique-validator": "^2.0.3","popper.js": "^1.16.1","rxjs": "~6.5.3","tslib": "^2.2.0","zone.js": "~0.11.4"
  },"devDependencies": {
    "@angular-devkit/build-angular": "~12.0.0","@angular/cli": "^12.0.0","@angular/compiler-cli": "^12.0.0","@types/jasmine": "~3.7.2","@types/jasminewd2": "~2.0.9","@types/node": "^15.0.3","codelyzer": "^6.0.2","jasmine-core": "~3.7.1","jasmine-spec-reporter": "~7.0.0","karma": "~6.3.2","karma-chrome-launcher": "~3.1.0","karma-coverage-istanbul-reporter": "~3.0.3","karma-jasmine": "~4.0.1","karma-jasmine-html-reporter": "^1.6.0","nodemon": "^2.0.7","protractor": "~7.0.0","ts-node": "~9.1.1","tslint": "~6.1.0","typescript": "~4.2.4"
  }
}

tsconfig.app.json 文件


{
  "extends": "./tsconfig.base.json","compilerOptions": {
    "outDir": "./out-tsc/app","types": []
  },"angularCompilerOptions":{
    "enableIvy": true,"strictTemplates": true,"strictInjectionParameters": true
  },"files": [
    "src/main.ts","src/polyfills.ts"
  ],"include": [
    "src/**/*.d.ts"
  ]
}

如果需要有关任何文件的更多信息,请询问。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)