LoginSignup
4
4

More than 5 years have passed since last update.

(Mac版)BluemixのNode.jsアプリをローカル環境で実行する

Last updated at Posted at 2015-06-03

ローカル環境でBluemixのNode.jsアプリを実行する方法は下記に記載されています。が、Macの場合ちょっとだけ手順が異なるので補足。

BluemixにデプロイしたNode.jsアプリが起動しない!そんなときは、ローカル環境で確認しましょう

上記にもありますが、BluemixのNode.jsはVCAP_SERVICESという環境変数を使っているので「OSの環境変数にVCAP_SERVICESを定義する」必要があります。

ので、 Bluemixアプリの[概要]-[環境変数]をまず確認して、コピーします(ここは上記記事と一緒です)。

vcap_service.png

そして、Macの場合、ターミナルから下記のように実行してVCAP_SERVICEを定義します。
export VCAP_SERVICES='{"cloudantNoSQLDB": [
{
"name": "Cloudant NoSQL DB-i1",
"label": "cloudantNoSQLDB",
"plan": "Shared",
"credentials": {
"username": "xxxxxx-xxxx-xxxx-xxxx-xxxxxxxx-bluemix",
"password": "xxxxxxxxxxxxxxxxxx",
"host": "xxxxx-xxxxx-xxx-xxx-xxxxxxxx-bluemix.cloudant.com",
"port": 443,
"url": "https://xxxxxxxxxxxxxxx-bluemix.cloudant.com"
}
}
]
}'

export VCAP_SERVICES= の後に、環境変数をシングルクォーテーション(')で囲っています。その後、'node app.js' で実行できます。

単に、ターミナルのコマンドの書き方の話といえばそれまでなのですが、ちょっとハマってしまったのでメモしてみました。

4
4
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
4
4