简体   繁体   English

Angular 2 + Rails 5 Heroku部署错误(bash:npm:未找到命令)

[英]Angular 2 + Rails 5 Heroku deployment error (bash: npm: command not found)

Deploying an Angular2 on Rails5 app to Heroku resulted in a successful build without errors. 将Angular2 on Rails5应用程序部署到Heroku可以成功构建而不会出现错误。 I then set up my PG database without incident. 然后,我无故障地建立了我的PG数据库。 When trying to access the app, I get the below stack trace from the Heroku app log. 尝试访问该应用程序时,我从Heroku应用程序日志中获得以下堆栈跟踪。 Trying to figure out why the npm: command not found is thrown. 试图找出为什么未找到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 head 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"
 },

When trying to hit the app url, the Heroku app log throws the below error code: 尝试访问应用程序URL时,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=

Update: I added a Procfile to the project's root directory with the below entries. 更新:我使用以下条目将Procfile添加到项目的根目录中。 The rails app now starts as a result of the entry but still getting bash: npm: command not found. 现在,Rails应用程序会由于输入而启动,但仍会出现bash:npm:命令未找到的情况。

Procfile: 程序文件:

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

Remaining error: 剩余错误:

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

Modified package.json to account for starting the Angular2 app during the heroku post-build step. 修改了package.json以说明在heroku后构建步骤中启动Angular2应用程序的过程。 Keeping it after && ensured that it would only kickoff if the preceding step completed. 在&&之后保留它,以确保仅在上一步完成后才能启动。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM