Node.js配置好后,总要搞点啥吧,还是从山寨个微博开始。
1.express install
npm install expressnpm install -g express-generator@3//express 命令行从4.x开始单独分出一个模块,单独安装
2.搭建microblog
题外话,我是ubuntu 14.04 64位,
sudo apt-get install nodejs后/usr/bin下只有nodejs没有node,使用不方便,建个软连接sudo ln -s /usr/bin/nodejs /usr/bin/node
这样express命令行里可以运行了
express -t ejs microblog
create : microblog create : microblog/package.json create : microblog/app.js create : microblog/public create : microblog/public/javascripts create : microblog/public/images create : microblog/public/stylesheets create : microblog/public/stylesheets/style.css create : microblog/routes create : microblog/routes/index.js create : microblog/routes/user.js create : microblog/views create : microblog/views/index.jade create : microblog/views/layout.jade create : microblog/views/error.jade create : microblog/bin create : microblog/bin/www install dependencies: $ cd microblog && npm install run the app: $ DEBUG=my-application ./bin/www
不要忘了进入目录npm install因为还没装完
cd microblog && npm install
返回
debug@0.7.4 node_modules/debugstatic-favicon@1.0.2 node_modules/static-faviconcookie-parser@1.0.1 node_modules/cookie-parser├── cookie-signature@1.0.3└── cookie@0.1.0morgan@1.0.1 node_modules/morgan└── bytes@0.3.0body-parser@1.0.2 node_modules/body-parser├── qs@0.6.6├── raw-body@1.1.7 (string_decoder@0.10.25-1, bytes@1.0.0)└── type-is@1.1.0 (mime@1.2.11)jade@1.3.1 node_modules/jade├── character-parser@1.2.0├── commander@2.1.0├── mkdirp@0.3.5├── transformers@2.1.0 (promise@2.0.0, css@1.0.8, uglify-js@2.2.5)├── constantinople@2.0.0 (uglify-js@2.4.14)├── with@3.0.0 (uglify-js@2.4.14)└── monocle@1.1.51 (readdirp@0.2.5)express@3.4.8 node_modules/express├── methods@0.1.0├── merge-descriptors@0.0.1├── range-parser@0.0.4├── cookie-signature@1.0.1├── fresh@0.2.0├── buffer-crc32@0.2.1├── cookie@0.1.0├── mkdirp@0.3.5├── commander@1.3.2 (keypress@0.1.0)├── send@0.1.4 (mime@1.2.11)└── connect@2.12.0 (uid2@0.0.3, pause@0.0.1, qs@0.6.6, bytes@0.2.1, raw-body@1.1.2, batch@0.5.0, negotiator@0.3.0, multiparty@2.2.0)
好了,运行下DEBUG=my-application ./bin/www浏览器打开127.0.0.1:3000看下,可以了。
3.