这是使用heroku logs --tail
的日志
我不知道怎么了:(
2019-07-23T14:46:07.163085+00:00 app[api]: Release v1 created by user *************************
2019-07-23T14:46:07.163085+00:00 app[api]: Initial release by user *************************
2019-07-23T14:46:07.294081+00:00 app[api]: Release v2 created by user *************************
2019-07-23T14:46:07.294081+00:00 app[api]: Enable Logplex by user *************************
2019-07-23T18:01:44.000000+00:00 app[api]: Build started by user *************************
2019-07-23T18:03:07.000000+00:00 app[api]: Build failed -- check your build output: https://dashboard.heroku.com/apps/8caccb7a-a433-493d-908c-1a4c74cd9fdd/activity/builds/aed091e8-1bfb-4307-83cf-43ada72e2861
2019-07-23T18:09:36.063934+00:00 heroku[router]: at=info code=H81 desc="Blank app" method=GET path="/" host=test-sales-inventory.herokuapp.com request_id=7616d3f6-076f-4304-a0c2-8500acab1f52 fwd="119.94.134.58" dyno= connect= service= status=502 bytes= protocol=http
2019-07-23T18:09:36.516265+00:00 heroku[router]: at=info code=H81 desc="Blank app" method=GET path="/favicon.ico" host=test-sales-inventory.herokuapp.com request_id=930f88f0-be45-4d53-8b7c-4d853c6feefe fwd="119.94.134.58" dyno= connect= service= status=502 bytes= protocol=http
2019-07-23T18:11:32.000000+00:00 app[api]: Build started by user *************************
2019-07-23T18:12:49.000000+00:00 app[api]: Build failed -- check your build output: https://dashboard.heroku.com/apps/8caccb7a-a433-493d-908c-1a4c74cd9fdd/activity/builds/f3821a02-3652-4d9e-9d42-e31f66082ae5
2019-07-24T03:57:07.991461+00:00 heroku[router]: at=info code=H81 desc="Blank app" method=GET path="/" host=test-sales-inventory.herokuapp.com request_id=ca49428f-93a7-476b-b98e-7d677a399c4b fwd="192.46.82.6" dyno= connect= service= status=502 bytes= protocol=https
2019-07-24T03:57:09.494625+00:00 heroku[router]: at=info code=H81 desc="Blank app" method=GET path="/favicon.ico" host=test-sales-inventory.herokuapp.com request_id=08526607-c300-43d9-9990-24bea733905f fwd="192.46.82.6" dyno= connect= service= status=502 bytes= protocol=https
2019-07-24T05:42:30.000000+00:00 app[api]: Build started by user *************************
2019-07-24T05:43:12.000000+00:00 app[api]: Build failed -- check your build output: https://dashboard.heroku.com/apps/8caccb7a-a433-493d-908c-1a4c74cd9fdd/activity/builds/391584f4-51f0-4d1e-8a32-0e0e872ad633
2019-07-24T05:44:53.000000+00:00 app[api]: Build started by user *************************
2019-07-24T05:46:03.000000+00:00 app[api]: Build failed -- check your build output: https://dashboard.heroku.com/apps/8caccb7a-a433-493d-908c-1a4c74cd9fdd/activity/builds/a145e335-4664-4a14-8534-bce8059d3e45
2019-07-24T05:47:35.409299+00:00 heroku[router]: at=info code=H81 desc="Blank app" method=GET path="/" host=test-sales-inventory.herokuapp.com request_id=adf69c0e-65d4-41f4-bb88-d25b4a0c72d7 fwd="192.46.82.6" dyno= connect= service= status=502 bytes= protocol=http
2019-07-24T05:47:36.211822+00:00 heroku[router]: at=info code=H81 desc="Blank app" method=GET path="/favicon.ico" host=test-sales-inventory.herokuapp.com request_id=9009ad97-58ec-4faa-a69a-09d0acfcf895 fwd="192.46.82.6" dyno= connect= service= status=502 bytes= protocol=http
2019-07-24T05:48:48.000000+00:00 app[api]: Build started by user *************************
2019-07-24T05:52:39.551161+00:00 app[api]: Deploy 99fb36a8 by user *************************
2019-07-24T05:52:39.551161+00:00 app[api]: Release v3 created by user *************************
2019-07-24T05:52:39.571172+00:00 app[api]: Scaled to web@1:Free by user *************************
2019-07-24T05:52:46.260351+00:00 heroku[web.1]: Starting process with command `npm start`
2019-07-24T05:52:49.243475+00:00 heroku[web.1]: State changed from starting to crashed
2019-07-24T05:52:49.248877+00:00 heroku[web.1]: State changed from crashed to starting
2019-07-24T05:52:49.161557+00:00 app[web.1]:
2019-07-24T05:52:49.161578+00:00 app[web.1]: > sales-and-inventory@1.0.0 start /app
2019-07-24T05:52:49.161580+00:00 app[web.1]: > ng serve
2019-07-24T05:52:49.161581+00:00 app[web.1]:
2019-07-24T05:52:49.166940+00:00 app[web.1]: sh: 1: ng: not found
2019-07-24T05:52:49.170658+00:00 app[web.1]: npm ERR! file sh
2019-07-24T05:52:49.170864+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-07-24T05:52:49.171023+00:00 app[web.1]: npm ERR! errno ENOENT
2019-07-24T05:52:49.171203+00:00 app[web.1]: npm ERR! syscall spawn
2019-07-24T05:52:49.172192+00:00 app[web.1]: npm ERR! sales-and-inventory@1.0.0 start: `ng serve`
2019-07-24T05:52:49.172292+00:00 app[web.1]: npm ERR! spawn ENOENT
2019-07-24T05:52:49.172500+00:00 app[web.1]: npm ERR!
2019-07-24T05:52:49.172620+00:00 app[web.1]: npm ERR! Failed at the sales-and-inventory@1.0.0 start script.
2019-07-24T05:52:49.172723+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-07-24T05:52:49.179364+00:00 app[web.1]:
2019-07-24T05:52:49.179517+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-07-24T05:52:49.179606+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2019-07-24T05_52_49_174Z-debug.log
2019-07-24T05:52:49.222034+00:00 heroku[web.1]: Process exited with status 1
2019-07-24T05:52:54.000000+00:00 app[api]: Build succeeded
2019-07-24T05:52:55.609389+00:00 heroku[web.1]: Starting process with command `npm start`
2019-07-24T05:52:57.560798+00:00 heroku[web.1]: State changed from starting to crashed
2019-07-24T05:52:57.538094+00:00 heroku[web.1]: Process exited with status 1
2019-07-24T05:52:57.439444+00:00 app[web.1]:
2019-07-24T05:52:57.439464+00:00 app[web.1]: > sales-and-inventory@1.0.0 start /app
2019-07-24T05:52:57.439466+00:00 app[web.1]: > ng serve
2019-07-24T05:52:57.439467+00:00 app[web.1]:
2019-07-24T05:52:57.477143+00:00 app[web.1]: sh: 1: ng: not found
2019-07-24T05:52:57.481380+00:00 app[web.1]: npm ERR! file sh
2019-07-24T05:52:57.481590+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-07-24T05:52:57.481731+00:00 app[web.1]: npm ERR! errno ENOENT
2019-07-24T05:52:57.481866+00:00 app[web.1]: npm ERR! syscall spawn
2019-07-24T05:52:57.482878+00:00 app[web.1]: npm ERR! sales-and-inventory@1.0.0 start: `ng serve`
2019-07-24T05:52:57.482985+00:00 app[web.1]: npm ERR! spawn ENOENT
2019-07-24T05:52:57.483185+00:00 app[web.1]: npm ERR!
2019-07-24T05:52:57.483289+00:00 app[web.1]: npm ERR! Failed at the sales-and-inventory@1.0.0 start script.
2019-07-24T05:52:57.483387+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-07-24T05:52:57.489648+00:00 app[web.1]:
2019-07-24T05:52:57.489807+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-07-24T05:52:57.489875+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2019-07-24T05_52_57_484Z-debug.log
2019-07-24T05:53:04.457510+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=test-sales-inventory.herokuapp.com request_id=234286bc-3934-48e2-9315-ff79a4aa5264 fwd="192.46.82.6" dyno= connect= service= status=503 bytes= protocol=http
2019-07-24T05:53:05.913904+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=test-sales-inventory.herokuapp.com request_id=969b41f7-3cea-4341-b75f-a69ba41393ac fwd="192.46.82.6" dyno= connect= service= status=503 bytes= protocol=http
2019-07-24T05:53:40.892802+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=test-sales-inventory.herokuapp.com request_id=777a3c0c-1879-4a17-ade0-4ae56490b7e9 fwd="192.46.82.6" dyno= connect= service= status=503 bytes= protocol=http
2019-07-24T05:53:41.594862+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=test-sales-inventory.herokuapp.com request_id=e8db9ab8-a1ce-4a3d-a3a3-8f716d2b8309 fwd="192.46.82.6" dyno= connect= service= status=503 bytes= protocol=http
2019-07-24T05:53:59.658086+00:00 app[api]: Starting process with command `heroku logs --tail` by user *************************
2019-07-24T05:54:08.647493+00:00 heroku[run.1033]: State changed from starting to up
2019-07-24T05:54:08.739914+00:00 heroku[run.1033]: State changed from up to complete
2019-07-24T05:54:08.665945+00:00 heroku[run.1033]: Awaiting client
2019-07-24T05:54:08.710594+00:00 heroku[run.1033]: Error R13 (Attach error) -> Failed to attach to process
2019-07-24T05:54:08.713926+00:00 heroku[run.1033]: Process exited with status 128
这是我的角度应用程序的package.json
{
"name": "sales-and-inventory",
"version": "1.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"install:clean": "rm -rf node_modules/ && rm -rf package-lock.json && npm install && npm start",
"heroku-postbuild": "ng build --prod"
},
"private": true,
"dependencies": {
"@angular/animation": "^4.0.0-beta.8",
"@angular/animations": "7.2.4",
"@angular/cdk": "^7.2.4",
"@angular/common": "7.2.4",
"@angular/compiler": "7.2.4",
"@angular/core": "7.2.4",
"@angular/forms": "7.2.4",
"@angular/http": "7.2.4",
"@angular/material": "^7.2.4",
"@angular/platform-browser": "7.2.4",
"@angular/platform-browser-dynamic": "7.2.4",
"@angular/router": "7.2.4",
"@ng-bootstrap/ng-bootstrap": "4.0.1",
"@ng-select/ng-select": "^2.20.0",
"bootstrap": "4.1.3",
"chart.js": "2.7.3",
"clipboard": "2.0.4",
"core-js": "2.6.4",
"ngx-clipboard": "11.1.9",
"ngx-toastr": "9.1.2",
"nouislider": "13.1.1",
"rxjs": "6.4.0",
"zone.js": "0.8.29",
"typescript": "3.2.4"
},
"devDependencies": {
"@angular-devkit/build-angular": "0.13.1",
"@angular/cli": "7.3.1",
"@angular/compiler-cli": "7.2.4",
"@angular/language-service": "7.2.4",
"@types/jasmine": "3.3.8",
"@types/jasminewd2": "2.0.6",
"@types/node": "11.9.0",
"codelyzer": "4.5.0",
"enhanced-resolve": "^3.3.0",
"jasmine-core": "3.3.0",
"jasmine-spec-reporter": "4.2.1",
"karma": "^4.1.0",
"karma-chrome-launcher": "2.2.0",
"karma-coverage-istanbul-reporter": "2.0.4",
"karma-jasmine": "2.0.1",
"karma-jasmine-html-reporter": "1.4.0",
"protractor": "5.4.2",
"ts-node": "8.0.2",
"tslint": "5.12.1",
"typescript": "3.2.4"
},
"engines": {
"node": "10.15.0",
"npm": "6.4.1"
}
}
我也插入了这个代码
app.use(express.static(__dirname + '/dist/sales-and-inventory'));
app.get('/*', function(req,res) {
res.sendFile(path.join(__dirname+'/dist/sales-and-inventory>/index.html'));
});
在我的角度文件夹中,有一个名为"Back"的文件夹,我的后端在哪里。 以下是获取我的服务器的方法.js返回 => 应用程序 => 配置 =>服务器.js
问题出在您的 Package.json 文件上。
当 heroku 部署 nodejs 应用程序时,它会自动运行npm start
脚本。
在您的情况下,npm start
脚本定义为ng serve
。而且,正如 Heroku 日志告诉您的那样:"ng:未找到"。
答案就在这个 Angular CLI 问题中。
在其中,他们建议在您的 package.json 文件中:
移动
"@angular/cli": "7.3.1",
"@angular/compiler-cli": "7.2.4",
从"devDependencies"
到"dependencies"
,"因为这是缺失的ng错误。此外,更改heroku-postbuild
的postinstall
,因为它可以实现相同的目标,但在本地安装 deps 时不会触发构建">