http://www.linuxidc.com/Linux/2012-10/72627.htmhtml
see version java
node --version
helloworld.jsnode
var http = require('http'); server = http.createServer(function (req, res) { res.writeHeader(200, {"Content-Type": "text/plain"}); res.end("Hello World\n"); }) server.listen(8000); console.log("httpd start @8000");
run on DOS
jquery
node helloworld.js
enter the url in explorerlinux
http://localhost:8000/
you will see "Hello World"git
npm:sql
node.js+express.js+monent.js
mongodb
mongodb+mongooseexpress
jadenpm
Bower:
jQuery
Bootstrap
npm install express jade moment mongoose mongodb
Q: error enoent stat
A: C:\Users\Administrator\AppData\Roaming\ 在這個目錄創建npm文件夾
app.js (入口文件)
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('server started') //index page app.get('/', function(req, res){ res.render('index',{ title : 'index page' }) }) //detail page app.get('/movie/:id', function(req, res){ res.render('detail',{ title : 'detail page' }) }) //admin(add) page app.get('/admin/movie', function(req, res){ res.render('admin',{ title : 'admin page' }) }) //list page app.get('/admin', function(req, res){ res.render('list',{ title : 'list page' }) })
index.jade, detail.jade, admin.jade, list.jade
doctype html head meta(charset="utf-8") title #{title} body h1 #{title}
dos
node app.js
see on explorer
index page: http://localhost:3000 detail page: http://localhost:3000/movie/1 admin(add) page: http://localhost:3000/admin/movie list page: http://localhost:3000/admin
--------------------------
安裝bower(全局global)
npm install bower -g
安裝bootstrap(依賴jquery)
bower install bootstrap
A: Bower : ENOGIT git is not installed or not in the PATH
Q:安裝git
npm install body-parser
Q:
(like bodyParser) is no longer bundled with Express and m ust be installed separately.
A: http://www.tuicool.com/articles/vaiyMb
var bodyParser = require('body-parser'); // parse application/x-www-form-urlencoded app.use(bodyParser.urlencoded({ extended: false })) // parse application/json app.use(bodyParser.json())
npm install underscore
Q: errno:10061 因爲目標計算機積極拒絕,沒法鏈接。
A: http://www.cnblogs.com/xiaoit/p/3867573.html
Q: cannot find module 'regexp-clone'/'sliced'/'mpath'/'ms'/'mquery'...
A:
npm install regexp-clone sliced mpath ms mquery hooks mpromise muri
以上都是mongoose安裝包,多是因爲沒有把mongoose安裝好形成