Я пытаюсь запустить приложение Angular на Heroku. Я прочитал много руководств, но решения не работают в моем случае. Сборка приложения прошла успешно на Heroku. Однако при запуске приложения возникает ошибка.
пакет. json
{
"name": "angular-heroku",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "node server.js",
"postinstall": "ng build --aot --prod",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "~9.1.3",
"@angular/common": "~9.1.3",
"@angular/compiler": "~9.1.3",
"@angular/core": "~9.1.3",
"@angular/forms": "~9.1.3",
"@angular/platform-browser": "~9.1.3",
"@angular/platform-browser-dynamic": "~9.1.3",
"@angular/router": "~9.1.3",
"rxjs": "~6.5.4",
"tslib": "^1.10.0",
"zone.js": "~0.10.2"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.901.3",
"@angular/cli": "~9.1.3",
"@angular/compiler-cli": "~9.1.3",
"@angular/language-service": "~9.1.3",
"@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"
}
}
сервер. js
const express = require('express');
const app = express();
app.use(express.static(__dirname + '/dist/angular-heroku'));
app.post('/*', function(req, res){
res.sendFile(__dirname + '/dist/angular-heroku/index.html');
});
app.listen(4200);
index. html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>AngularHeroku</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
hello
<app-root></app-root>
</body>
</html>
app.component. html
world
журналы приложений heroku
Мне просто нужен пример кода того, как запустить пример приложения Angular 9 (возможно, Angular 8) на Heroku. Пожалуйста, помогите :(