1

Rails API バックエンド アプリを作成し、アプリ内のクライアント フォルダーにフロントエンド用の create-react-app を作成しました。私のローカル マシンでは問題なく動作しますが、heroku ではエラーが発生して動作しません。

npm: command not found

アプリの構造は次のとおりです。

rails-app
  - app
     - controller
     - model
     - ...
  - client
     - package.json
     - index.jsx
     - ...
  - config
  - db
  - ...
  - Procfile

私が持っているProfileの中に:

web: cd client && npm start
api: bundle exec rails s -p 3001

package.json 内:

{
  "name": "client",
  "version": "0.1.0",
  "private": true,
  "proxy": "http://localhost:3001/",
  "devDependencies": {
    "react-scripts": "0.6.1"
  },
  "dependencies": {
    "babel-loader": "^6.2.5",
    "babel-preset-es2015": "^6.14.0",
    "babel-preset-react": "^6.11.1",
    "firebase": "^3.4.1",
    "jquery": "^3.1.1",
    "react": "^15.3.2",
    "react-dom": "^15.3.2"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  }
}

(Rails バックエンドと通信するプロキシに注意してください)

ヘロク: ここに画像の説明を入力

Heroku ログ:

2016-09-29T15:12:31.193617+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=strv-address-book.herokuapp.com request_id=bc33286a-3dd3-475f-b974-a00c5aee42f7 fwd="151.227.204.173" dyno= connect= service= status=503 bytes=
2016-09-29T15:12:44.403333+00:00 heroku[api.1]: Restarting
2016-09-29T15:12:44.404060+00:00 heroku[api.1]: State changed from up to starting
2016-09-29T15:12:45.064536+00:00 heroku[web.1]: State changed from crashed to starting
2016-09-29T15:12:47.345132+00:00 heroku[api.1]: Starting process with command `bundle exec rails s -p 3001`
2016-09-29T15:12:47.459080+00:00 heroku[web.1]: Starting process with command `cd client && npm start`
2016-09-29T15:12:47.931743+00:00 heroku[api.1]: State changed from starting to up
2016-09-29T15:12:48.531931+00:00 heroku[api.1]: Stopping all processes with SIGTERM
2016-09-29T15:12:49.283096+00:00 heroku[web.1]: State changed from starting to crashed
2016-09-29T15:12:49.263399+00:00 heroku[web.1]: Process exited with status 127
2016-09-29T15:12:49.036142+00:00 app[web.1]: bash: npm: command not found
2016-09-29T15:12:49.352458+00:00 app[api.1]: - Gracefully stopping, waiting for requests to finish
2016-09-29T15:12:49.352608+00:00 app[api.1]: === puma shutdown: 2016-09-29 15:12:49 +0000 ===
2016-09-29T15:12:49.352645+00:00 app[api.1]: - Goodbye!
2016-09-29T15:12:49.352737+00:00 app[api.1]: Exiting
2016-09-29T15:12:49.480691+00:00 heroku[api.1]: Process exited with status 0
2016-09-29T15:12:50.284874+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=strv-address-book.herokuapp.com request_id=c262f174-97c8-4326-a20b-3f13f2f6e99b fwd="151.227.204.173" dyno= connect= service= status=503 bytes=
2016-09-29T15:12:50.976612+00:00 app[api.1]: => Rails 5.0.0.1 application starting in production on http://0.0.0.0:3001
2016-09-29T15:12:50.976587+00:00 app[api.1]: => Booting Puma
2016-09-29T15:12:50.976617+00:00 app[api.1]: => Run `rails server -h` for more startup options
2016-09-29T15:12:51.938112+00:00 app[api.1]: Puma starting in single mode...
2016-09-29T15:12:51.938132+00:00 app[api.1]: * Version 3.6.0 (ruby 2.3.0-p0), codename: Sleepy Sunday Serenity
2016-09-29T15:12:51.938133+00:00 app[api.1]: * Min threads: 5, max threads: 5
2016-09-29T15:12:51.938134+00:00 app[api.1]: * Environment: production
2016-09-29T15:12:51.938225+00:00 app[api.1]: * Listening on tcp://0.0.0.0:3001
2016-09-29T15:12:51.938543+00:00 app[api.1]: Use Ctrl-C to stop
2016-09-29T15:12:52.380906+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=strv-address-book.herokuapp.com request_id=5d5f2cbb-4fd0-40f2-a8d4-86c2b8cf14f3 fwd="151.227.204.173" dyno= connect= service= status=503 bytes=

(エラーなしで heroku run rails c を実行できます)

反応アプリについてherokuに伝える方法、またはどうすれば機能させることができますか?

4

1 に答える 1