Node JS 練習紀錄

下午1:47:00


1.安裝Node.js (http://nodejs.org/)

安裝以下package
npm install exptess -g
npm install jade -g
npm install mongooose -g
npm install bower -g
bower install bootstrap


mac下推薦是 mac 系统下一个命令行的增强工具,叫做 iTerm,里面彩色的样式是通过 oh-my-zsh 插件配置实现

1. Mac 下安裝 Bower 會先碰到 ECMDRR exit code #69
解學方案 : Had to run sudo xcodebuild -license then agree to it at the bottom.



var express = require('express') var port = process.env.PORT || 3000 var app = express() app.set('views', './views') app.set('view engine', 'jade') app.listen(port) console.log('web start port' + port) // index page app.get('/' , function(req, res){ res.render('index',{ title: 'Kai node.js index 頁面' }) }) // list page app.get('/admin/list' , function(req, res){ res.render('list',{ title: 'Kai node.js list 頁面' }) }) // detail page app.get('/detail' , function(req, res){ res.render('detail',{ title: 'Kai node.js detail 頁面' }) }) // admin page app.get('/admin/movide' , function(req, res){ res.render('admin',{ title: 'Kai node.js admin 頁面' }) })



doctype html head meta(charset="utf-8") title #{title} body h1 #{title}
技術提供:Blogger.