2015年5月28日 星期四

Express JS 安裝 on Window

最新的使用方法:

Express application generator 

參考以上連結,直接從這邊開始做即可:
$ npm install express-generator -g
-g 全域安裝,安裝到 C:\Users\使用者名稱\AppData\Roaming\npm\node_modules,
之後就可以直接用 express myApp 去生出一個網站,
等到 cd myApp,再 npm install 就會將 express 給安裝進來,
隨後即可用 npm start 執行 localhost Server。

以下的實驗記錄還能用,但是比較老舊的作法。
Refer to http://expressjs.com/ .

cd to the director of nodejs (where "node_modules" is contained)
$ npm install express
$ npm install express-generator

cd to the directory of express-generator (exprss-generator/bin)
$node ./bin/express -e microBlog ($node express -e microBlog)
, where -e means ejs template is used.

cd to the directory of microBlog
Then install dependencies:
$ npm install

Run the app (on MacOS or Linux):
$ DEBUG=microBlog npm start

On Windows, use this command:
> set DEBUG=microBlog:* & npm start

Then load http://localhost:3000/ in your browser to access the app.

The generated app directory structure looks like the following.
.
├── app.js
├── bin
│   └── www
├── package.json
├── public
│   ├── images
│   ├── javascripts
│   └── stylesheets
│       └── style.css
├── routes
│   ├── index.js
│   └── users.js
└── views
    ├── error.jade
    ├── index.jade
    └── layout.jade

7 directories, 9 files

沒有留言: