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