0

我希望将我的代码部署到 heroku,但是在构建我的 Angular 应用程序时我总是遇到错误。我尝试使用以下命令来构建我的 Angular 项目。'ng build --prod','ng build --aot --prod' 这两个命令都导致相同的错误。ng build --aot --prod 点击查看错误

附上我的 package.json,为 package-lock.json 添加了屏幕截图。packagelock.json 包锁

{
  "name": "blog-frontend",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "postinstall": "ng build --output-path angularapp  --aot --prod"
  },
  "e2e": "ng e2e",
  "private": true,
  "dependencies": {
    "@angular/animations": "^9.1.9",
    "@angular/cli": "~9.1.6",
    "@angular/common": "~9.1.7",
    "@angular/compiler": "~9.1.7",
    "@angular/compiler-cli": "~9.1.7",
    "@angular/core": "~9.1.7",
    "@angular/forms": "~9.1.7",
    "@angular/platform-browser": "~9.1.7",
    "@angular/platform-browser-dynamic": "~9.1.7",
    "@angular/router": "~9.1.7",
    "bootstrap": "^4.5.0",
    "express": "^4.17.1",
    "jquery": "^3.5.1",
    "ngx-toastr": "^12.0.1",
    "path": "^0.12.7",
    "rxjs": "~6.5.4",
    "tslib": "^1.10.0",
    "typescript": "~3.8.3",
    "zone.js": "~0.10.2"
  },
  "devDependencies": {
    "bootstrap": "^4.5.0",
    "@angular-devkit/build-angular": "~0.901.6",
    "@angular/cli": "~9.1.6",
    "@angular/compiler-cli": "~9.1.7",
    "@types/node": "^12.11.1",
    "@types/jasmine": "~3.5.0",
    "@types/jasminewd2": "~2.0.3",
    "codelyzer": "^5.1.2",
    "jasmine-core": "~3.5.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~5.0.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage-istanbul-reporter": "~2.1.0",
    "karma-jasmine": "~3.0.1",
    "karma-jasmine-html-reporter": "^1.4.2",
    "protractor": "~5.4.3",
    "ts-node": "~8.3.0",
    "tslint": "~6.1.0",
    "typescript": "~3.8.3"
  },
  "engines": {
    "node": "v12.16.3",
    "npm": "6.14.4"
  }
}

请帮忙

4

1 回答 1

0

当我使用以下命令构建 Angular 应用程序时,问题已解决

build --prod --named-chunks --verbose --build-optimizer=false --source-map

它指出了应用程序中存在语法的地方。解决后我的构建成功

于 2020-05-25T04:12:54.290 回答