日志进程中的应用程序崩溃错误退出,状态为0

时间:2019-05-15 21:45:38

标签: angular heroku web-hosting

  1. 我试图在Heroku上托管Anglar Web应用程序,但是当我尝试 建立我的专案,上面说建立成功,当我进入网路时 网址。它显示(应用程序错误)页面。
  2. 让我清楚一点,我正在使用Github存储库进行自动部署。
  3. 我的package.json是附加服务器。
  4. 我也正在使用这个tutorial寻求帮助。

Package.json文件

{
  "name": "web-app",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "node server.js",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "heroku-postbuild": "ng build --prod"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~7.2.0",
    "@angular/cli": "~7.3.8",
    "@angular/common": "~7.2.0",
    "@angular/compiler": "~7.2.0",
    "@angular/core": "~7.2.0",
    "@angular/forms": "~7.2.0",
    "@angular/platform-browser": "~7.2.0",
    "@angular/platform-browser-dynamic": "~7.2.0",
    "@angular/router": "~7.2.0",
    "core-js": "^2.5.4",
    "express": "^4.16.4",
    "path": "^0.12.7",
    "rxjs": "~6.3.3",
    "tslib": "^1.9.0",
    "zone.js": "~0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.13.0",
    "@angular/cli": "~7.3.8",
    "@angular/compiler-cli": "~7.2.0",
    "@angular/language-service": "~7.2.0",
    "@types/jasmine": "~2.8.8",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~8.9.4",
    "codelyzer": "~4.5.0",
    "enhanced-resolve": "^4.1.0",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~4.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",
    "typescript": "~3.2.2"
  },
  "engines": {
    "node": "10.15.3",
    "npm": "6.4.1"
  }
}

Server.js文件

//Install express server
const express = require('express');
const path = require('path');

const app = express();

// Serve only the static files form the dist directory
app.use(express.static(__dirname + '/dist/WebApp'));

app.get('/*', function(req,res) {

res.sendFile(path.join(__dirname+'/dist/WebApp/index.html'));
});

// Start the app by listening on the default Heroku port
// app.listen(process.env.PORT || 8080);
app.listen(process.env.PORT || 5000);

我的日志文件

2019-05-15T21:20:33.945586+00:00 heroku[web.1]: State changed from crashed to starting
2019-05-15T21:20:38.949356+00:00 heroku[web.1]: Starting process with command `npm start`
2019-05-15T21:20:40.922762+00:00 app[web.1]: 
2019-05-15T21:20:40.922781+00:00 app[web.1]: > web-app@0.0.0 start /app
2019-05-15T21:20:40.922783+00:00 app[web.1]: > node server.js
2019-05-15T21:20:40.922785+00:00 app[web.1]: 
2019-05-15T21:20:41.669398+00:00 heroku[web.1]: State changed from starting to up

0 个答案:

没有答案