LoginSignup
17
22

More than 5 years have passed since last update.

Node.jsアプリをHerokuへデプロイ

Posted at

毎回調べてしまうのでメモ。

package.json作成

Herokuはこれをみて依存関係を知るので必要です。

$ npm init

モジュールのインストール

モジュールのインストール時も気を付けなければなりません。
--save オプションをつけてpackage.jsonの依存関係に設定します。

$ npm install モジュール名 --save

Herokuへログイン

$ heroku login

Herokuアプリ作成

$ heroku create [アプリ名]

Git初期化

$ git init

.gitignore作成

公開したくないファイル(.envなど)を.gitignoreへ記入

Procfile作成

起動するためのコマンドをここに記入

例えば

Procfile
web: node app.js

Git追加

$ git add . 

Gitコミット

$ git commit -m "initial commit" 

Gitレポジトリ登録

$ heroku git:remote -a アプリ名

Gitプッシュ

$ git push heroku master

*Herokuのログ確認

Herokuアプリ公開後、ログをみたいときは

$ heroku logs -t

ターミナル以外でもHerokuのダッシュボードのMore > View logsからでも確認できます。

17
22
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
17
22