青空の月

PHP, Unity, C#, アプリ開発関連について。

node-configモジュールをインストールする

node.jsの実行環境に合わせて設定値を簡単に変えたいのでnode-configモジュールをインストールした。

 

公式サイト

https://github.com/lorenwest/node-config

http://lorenwest.github.io/node-config/latest/

 

フォルダ構成

.
├── example.js
├── config # 環境別設定ファイル用ディレクトリ
│   ├── development.json
│   └── production.json
├── node_modules
└── start.bat

 

 

windowsはstart.batで起動する。

 

https://github.com/masa795/node-config-test

 

実行するとこんな感じで指定したconfigフォルダの設定値が表示される。

========= Start ===========
NODE_ENV="development"
NODE_PATH="C:\node\node_modules"
port=9999
logging=true
env=development
ver=9999
=================================

 

 

 

参考にしたサイト

http://fukata.org/2011/11/27/nodejs-node-config/

http://d.hatena.ne.jp/sugyan/20110731/1312045169