nodejs 存档

nodejs express的使用

#全局安装express
npm install express-generator -g
express myapp

#create : myapp
#create : myapp/package.json
#create : myapp/app.js
#create : myapp/public
#create : myapp/public/javascripts
#create : myapp/public/images
#create : myapp/public/stylesheets
#create : myapp/public/stylesheets/style.css
#create : myapp/routes
#create : myapp/routes/index.js
#create : myapp/routes/users.js
#create : myapp/views
#create : myapp/views/index.jade
#create : myapp/views/layout.jade
#create : myapp/views/error.jade
#create : myapp/bin
#create : myapp/bin/www
#
#install dependencies:
#$ cd myapp && npm install
#
#run the app:
#$ DEBUG=myapp:* npm start

cd myapp/
ls
#app.js  bin  package.json  public  routes  views
sublime package.json #查看有那些依赖
npm install#下载这些依赖包
#npm http GET https://registry.npmjs.org/serve-favicon
#npm http GET https://registry.npmjs.org/cookie-parser
#npm http GET https://registry.npmjs.org/jade
#.
#.
#.
#.
#.
##下载各种依赖
#cookie-parser@1.3.5 node_modules/cookie-parser
#├── cookie@0.1.3
#└── cookie-signature@1.0.6
#
#debug@2.2.0 node_modules/debug
#└── ms@0.7.1
#.
#.
#.
#.
#.
#.
#完成
DEBUG=myapp npm start
#localhost:3000即可访问

http://www.expressjs.com.cn/starter/generator.html