本文共 3036 字,大约阅读时间需要 10 分钟。
express-generator 4.2
必须安装express-generator,否则找不到express命令
E:\work-express>express -V 4.2.0
(,新版本的express已经把express和express-generator)
顺便吐槽一下
【唉,express不同版本之间的变化很大。很多教程例子根本无法再最新的版本里面用。
那个使用mongoose保存session的,居然有好多种,一一试过,都得到了这种错误信息:
error: express的middleware已经把好多组件都从express中分离出来(比如session)
下面记录了这个操蛋的过程。
】
C:\Documents and Settings\Administrator\Application Data\npm\node_modules
node -v
0.10.26(ASUS, windows 7-64bit)
0.10.30(davidzhang-pc,windows xp-32bit)
npm -v
1.4.21(davidzhang-pc,windows xp-32bit)
express -V
4.2.0
nodejs.org
https://github.com/joyent/node (源代码安装,版本已经是0.11.x?)
cd /d D:\
express -e nodejs-demo
cd nodejs-demo
npm install
npm start
或者
node app.js
在浏览器里面打开
http://localhost:3000/
下载curl
http://curl.haxx.se/download/
选择下载:
curl-7.19.5-win32-nossl-sspi.zip
mongod.exe --dbpath D:/mongodb2.6/data/db
作为service
mongod --logpath D:/mongodb2.6/logs/mongodb.log --logappend --dbpath D:/mongodb2.6/data/db --directoryperdb --serviceName MongoDB --install
net start MongoDB
http://blog.fens.me/nodejs-express3/
----begin 在公司防火墙后面如何使用npm install--------
npm config set proxy=http://127.0.0.1:3128 npm config set https-proxy=https://127.0.0.1:3128
npm config get registry https://registry.npmjs.org/
#npm config set registry http://registry.npmjs.vitecho.com
npm config set registry http://registry.npmjs.org/
#http://127.0.0.1:3128 npm install
sudo npm install -g express
sudo npm install -g express-generator
apuser@jianzhangubtnb:~$ npm list -g |grep express ├─┬ express@4.8.1 ├─┬ express-generator@4.2.0
----end 在公司防火墙后面如何使用npm install--------
-----start 在supervisor下面运行----
sudo npm install -g supervisor
修改package.json文件中的scripts
把node替换成supervisor
"scripts": { "start": "supervisor ./bin/www" },
-----end 在supervisor下面运行----
-----start Migrating Express.js 3.x to 4.x---
// app.use(app.router); //deprecated
http://www.tuicool.com/articles/rAZfeihttp://expressjs.com/
-----end Migrating Express.js 3.x to 4.x---
-----start 修改routes路由表-----------
//app.use('/', routes); //app.use('/users', users); app.get('/', routes); app.get('/login', routes.login); app.post('/login', routes.doLogin); app.get('/logout', routes.logout); app.get('/home', routes.home);
-----end 修改routes路由表-----------
http://blog.csdn.net/liuzhoulong/article/details/6124566
---start Web-based MongoDB admin interface written with Node.js and express--
npm install -g mongo-express---end Web-based MongoDB admin interface written with Node.js and express--
{ "name": "nodejs-demo", "version": "0.0.1", "private": true, "scripts": { "start": "supervisor ./bin/www" }, "dependencies": { "body-parser": "~1.0.0", "cookie-parser": "~1.0.1", "debug": "~0.7.4", "ejs": "~0.8.5", "express": "~4.2.0", "express-session": "^1.7.5", "morgan": "~1.0.0", "session": "~0.1.0", "mongoose": "~3.8.14", "session-mongoose": "~0.5.0", "static-favicon": "~1.0.0" }}