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

ARS*_*ARS 6 javascript typescript angular ng-build

我想部署一个即将完成的 Angular 项目,为了部署我执行了 ng build --prod。它创建了一个 dist,然后我将其部署到服务器上。一切都明白了,直到这里,但现在当我更改项目中的内容并执行“ngserve -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)
Run Code Online (Sandbox Code Playgroud)

Chrome 控制台中的 Console.log() 消息在此输入图像描述

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"
  }
}
Run Code Online (Sandbox Code Playgroud)

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"
  ]
}
Run Code Online (Sandbox Code Playgroud)

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

Onu*_*kır 0

查看生产环境中错误的具体位置

ng build --prod --build-optimizer --sourceMap=true 你可以得到构建。

您的错误很可能是“??????” "UserzAccessStatus"您打印的对象中没有包含其名称的键。