LoginSignup
2
3

More than 5 years have passed since last update.

Express Windows7にインストール

Posted at

一通りnode.jsをいじってみたのでExpressを入れてみる。

npm install -g express

npm install -g express-generator

2行目のコマンドを忘れるとexpressコマンドが使えないから注意。

インストールが完了したら、アプリケーションを作成したいディレクトリに移動する。
(ちなみにwindowsだけどgit bushでコマンド打っている)

cd /c/web

移動後にexpressコマンドでアプリケーションを作成してみる。

express app

/c/web配下にappディレクトリが出来上がる。
コマンドログの最後に以下のように表示される。

# コマンドログ
install dependencies:
  $ cd app && npm install

run the app:
  $ DEBUG=app ./bin/www

./bin/wwwあるしもうrunできんの?と思って実行したら依存ファイルが無いと怒られるので言われたとおりにする。

cd app

npm install

npm installのコマンドログを見ると何が入ったかわかる。

# コマンドログ
debug@2.0.0 node_modules\debug
└── ms@0.6.2

cookie-parser@1.3.3 node_modules\cookie-parser
├── cookie@0.1.2
#省略

serve-favicon@2.1.7 node_modules\serve-favicon
├── fresh@0.2.4
#省略

morgan@1.3.2 node_modules\morgan
├── basic-auth@1.0.0
#省略

express@4.9.8 node_modules\express
├── range-parser@1.0.2
#省略

body-parser@1.8.4 node_modules\body-parser
├── raw-body@1.3.0
#省略

jade@1.6.0 node_modules\jade
├── character-parser@1.2.0
#省略

さて、いよいよ実行

node ./bin/www

#こっちでもOK
npm start

npm startはappディレクトリにある「app.js」から関連ファイルを遡って、
./bin/wwwを見つけ出して実行してるだけかな。

デフォルトポートの3000にアクセス。⇒ http://localhost:3000

Welcom to Express

と表示されればOK。

2
3
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
2
3