在Heroku上部署Angular时遇到错误R10(引导超时)

时间:2019-01-05 20:28:42

标签: angular heroku

我有一个基本的Angular App,我正在通过Travis-Ci在Heroku上进行部署。

  1. 我已将@ angular / cli,@ angular / compiler-cli,打字稿和@ angular-devkit / build-angular移至依赖项
  2. 我提到过“ preinstall”:“ npm install -g angular-cli”和“ postinstall”:“ ng build && mv dist / *”。在脚本中
  3. 我在package.json中提到了“引擎”

在travis和heroku中构建都成功。但是,当我运行该应用程序时,出现以下错误。

  

错误R10(引导超时)-> Web进程在启动后60秒内未能绑定到$ PORT

下面是配置。

.travis.yml

language: node_js
node_js:
- node
required: sudo
services:
- docker
deploy:
provider: heroku
app: angular-project-manager
api_key:
  secure: valid
before_script:
  - npm install -g @angular/cli
script:
  - ng build --prod --aot

heroku.yml

build:
docker:
web: dockerfile

package.json

{
 "name": "angular-project-manager",
 "version": "0.0.0",
 "scripts": {
   "ng": "ng",
   "start": "ng serve",
   "build": "ng build",
   "test": "ng test",
   "lint": "ng lint",
   "e2e": "ng e2e",
   "preinstall": "npm install -g angular-cli",
   "postinstall": "ng build && mv dist/* ."
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^6.1.0",
    "@angular/common": "^6.1.0",
    "@angular/compiler": "^6.1.0",
    "@angular/core": "^6.1.0",
    "@angular/forms": "^6.1.0",
    "@angular/http": "^6.1.0",
    "@angular/platform-browser": "^6.1.0",
    "@angular/platform-browser-dynamic": "^6.1.0",
    "@angular/router": "^6.1.0",
    "@ng-bootstrap/ng-bootstrap": "^4.0.1",
    "@types/lodash": "^4.14.119",
    "@types/typeahead": "^0.11.32",
    "bootstrap": "^4.2.1",
    "core-js": "^2.5.4",
    "fuse.js": "^3.3.0",
    "lodash": "^4.17.11",
    "ngx-typeahead": "^6.2.0",
    "rxjs": "~6.2.0",
    "zone.js": "~0.8.26",
    "@angular/cli": "~6.2.4",
    "@angular/compiler-cli": "^6.1.0",
    "typescript": "~2.9.2",
    "@angular-devkit/build-angular": "~0.8.0"
  },
 "devDependencies": {
   "@angular/language-service": "^6.1.0",
   "@types/jasmine": "~2.8.8",
   "@types/jasminewd2": "~2.0.3",
   "@types/node": "~8.9.4",
   "codelyzer": "~4.3.0",
   "jasmine-core": "~2.99.1",
   "jasmine-spec-reporter": "~4.2.1",
   "karma": "~3.0.0",
   "karma-chrome-launcher": "~2.2.0",
   "karma-coverage-istanbul-reporter": "~2.0.1",
   "karma-jasmine": "~1.1.2",
   "karma-jasmine-html-reporter": "^0.2.2",
   "protractor": "~5.4.0",
   "ts-node": "~7.0.0",
   "tslint": "~5.11.0"
 },
 "engines": {
   "node": "9.8.0",
   "npm": "5.6.0"
 }
}

1 个答案:

答案 0 :(得分:0)

我可以通过使用package.json中的以下语句解决问题。

 "start": "ng serve --port $PORT --host 0.0.0.0 --disable-host-check",