のぶLab.

流しのソフトウェアエンジニアの雑記帳. Android, Scala, Clojure, Ruby on Railsなど

YeomanでMEAN(MongoDB, Express, Angular.js, Node.js)アプリケーションを作る

こちらで紹介されている手順を参考に、
Yeomanを使ってMongoDB, Express, Angulaar.js, Node.jsで構成されたWebアプリケーションを立ち上げます。

前提

Yeomanはインストール済みの状態とします。
ちなみに私はBoxenを使ってインストールを行いました。
http://atsuya046.hatenablog.com/entry/2014/03/04/234757

MEANアプリケーション用genelatorのインストール

"generator-angular-fullstack"をインストールします。

npm install -g generator-angular-fullstack

MEANアプリケーション作成

mkdir mean_app
cd mean_app
yo angular-fullstack mean_app

インストールするものを聴かれます。
MongoDBがデフォルトでNなので注意して下さい。

起動

grunt serve

この時に以下のエラーが出る場合はMongoDBを起動していない可能性があります

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: failed to connect to [localhost:27017]

MongoDBを起動し、再度アプリケーションを起動して下さい。

mongod
grunt serve

ブラウザでYeomanで作成したアプリケーションが表示されればOKです。
http://localhost:9000