2016-11-25 97 views
0

在Rails5應用程序上部署一個Angular2到Heroku,導致無錯地成功構建。然後我設置我的PG數據庫沒有發生。當試圖訪問應用程序時,我從Heroku應用程序日誌中獲得下面的堆棧跟蹤。試圖找出爲什麼找不到npm:命令。Angular 2 + Rails 5 Heroku部署錯誤(bash:npm:命令沒有找到)

2016-11-25T00:30:40.044683+00:00 heroku[web.1]: State changed from 
crashed to starting 
2016-11-25T00:30:52.371722+00:00 heroku[web.1]: Starting process with 
command `npm start` 
2016-11-25T00:30:55.294652+00:00 app[web.1]: bash: npm: command not 
found 
2016-11-25T00:30:55.439571+00:00 heroku[web.1]: State changed from 
starting to crashed 
2016-11-25T00:30:55.409349+00:00 heroku[web.1]: Process exited with 
status 127 

的package.json頭

{ 
"name": "raven", 
"version": "0.0.1", 
"license": "MIT", 
"angular-cli": {}, 
"scripts": { 
    "start": "ng serve --proxy-config proxy.conf.json", 
    "start-phone": "ng serve --proxy-config proxy.conf.json --host 
    0.0.0.0", 
    "lint": "tslint \"src/**/*.ts\"", 
    "test": "ng test", 
    "pree2e": "webdriver-manager update", 
    "e2e": "protractor", 
    "heroku-postbuild": "ng build --prod" 
}, 

當試圖打的應用程序網址,Heroku的應用程序日誌拋出下面的錯誤代碼:

2016-11-25T00:35:43.573863+00:00 heroku[router]: at=error code=H10 
desc="App crashed" method=GET path="/" host=shrouded-shelf- 
15670.herokuapp.com request_id=92fba3d2-08e4-479d-8484-33f093c9c823 
fwd="75.173.239.214" dyno= connect= service= status=503 bytes= 

更新:我添加了一個Procfile到該項目的根目錄下面的條目。 Rails應用程序現在開始作爲輸入的結果,但仍然得到bash:npm:command not found。

Procfile:

web: sh -c 'cd ./client/ && exec npm start' 
api: rails s -p 3000 

剩餘誤差:

2016-11-25T02:17:14.955048+00:00 heroku[web.1]: Starting process with 
command `sh -c 'cd ./client/ && exec npm start'` 
2016-11-25T02:17:17.066308+00:00 heroku[web.1]: Process exited with 
status 127 
2016-11-25T02:17:16.983254+00:00 app[web.1]: sh: 1: exec: npm: not 
found 
2016-11-25T02:17:17.078868+00:00 heroku[web.1]: State changed from 
starting to crashed 

回答

0

改性的package.json以考慮在heroku上後生成步驟開始Angular2應用程序。在& &之後保持它只在前面的步驟完成時才起動。

"heroku-postbuild": "ng build --prod && npm start"