0

构建用于生产的 angular5 应用程序时出现以下错误。

ERROR in Either route or analyzedModules has to be specified!

推荐行 > ng build --prod --build-optimizer

我已经检查了Angular 5 production build throwing error,这对我来说不行。

这是我的 package.json

{
  "name": "hub-amber-web",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build --prod",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular-devkit/build-optimizer": "^0.6.8",
    "@angular/animations": "^5.2.10",
    "@angular/cdk": "^5.2.5",
    "@angular/common": "^5.2.10",
    "@angular/compiler": "^5.2.10",
    "@angular/core": "^5.2.10",
    "@angular/flex-layout": "^5.0.0-beta.14",
    "@angular/forms": "^5.2.10",
    "@angular/http": "^5.2.10",
    "@angular/material": "^5.2.5",
    "@angular/platform-browser": "^5.2.10",
    "@angular/platform-browser-dynamic": "^5.2.10",
    "@angular/router": "^5.2.10",
    "@auth0/angular-jwt": "^1.2.0",
    "@ng-bootstrap/ng-bootstrap": "^1.0.0-beta.9",
    "@ngrx/store": "^5.2.0",
    "@ngrx/store-devtools": "^5.2.0",
    "ajv": "^6.5.0",
    "angular-calendar": "^0.24.1",
    "angular-font-awesome": "^3.1.2",
    "angularfire2": "^5.0.0-rc.5-next",
    "bootstrap": "^4.1.1",
    "classlist.js": "^1.1.20150312",
    "core-js": "^2.5.6",
    "firebase": "^4.13.1",
    "font-awesome": "^4.7.0",
    "hammerjs": "^2.0.8",
    "jwt-decode": "^2.2.0",
    "material-design-icons": "^3.0.1",
    "moment": "^2.22.1",
    "ng-pick-datetime": "5.2.6",
    "ng-pick-datetime-moment": "^1.0.6",
    "rxjs": "^5.5.10",
    "save": "^2.3.2",
    "time-ago-pipe": "^1.3.2",
    "web-animations-js": "^2.3.1",
    "zone.js": "^0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.6.0",
    "@angular/cli": "6.0.7",
    "@angular/compiler-cli": "6.0.7",
    "@angular/language-service": "^5.2.10",
    "@types/jasmine": "^2.8.7",
    "@types/jasminewd2": "~2.0.2",
    "@types/node": "^6.0.110",
    "angular-ide": "^0.9.40",
    "codelyzer": "^4.3.0",
    "html-webpack-plugin": "^3.2.0",
    "jasmine-core": "~2.8.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "^2.0.2",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "^1.4.2",
    "karma-jasmine": "^1.1.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.1.2",
    "ts-node": "~4.1.0",
    "tslint": "~5.9.1",
    "typescript": "~2.7.2",
    "webpack": "^4.8.3",
    "webpack-dev-server": "^3.1.4"
  }
}   
4

1 回答 1

1

面对同样的问题,

在将 "typescript" 从 "^2.4.2" 更新为 "2.7.2" 和 "@angular/compiler-cli": "^5.0.0" 到 "^6.0.7" 之后出现

使用 "@angular/core": "^5.0.0" 构建 "ng build --prod --sourcemaps"。

降级到 "@angular/compiler-cli": "5.2.11" 并调整 "typescript": "2.6.1" 后,它对我有用。

于 2018-07-03T12:37:38.830 回答