1. 安裝nodenode
2. 安裝pythonpython
3. 安裝connect, serve-static和node-livereload (如下都假設命令行當前目錄爲e:\WebSite)web
e:\WebSite>npm install connectchrome
e:\WebSite>npm install serve-staticnpm
e:\WebSite>npm install livereload瀏覽器
若是出現相似:MSB8036: The Windows SDK version 8.1 was not found的錯誤,請使用Visual Studio安裝包安裝"Tools and Windows SDKs"app
4. 安裝Google Chrom 插件 LiveReloadui
https://chrome.google.com/webstore/detail/jnihajbhpnppcggbcgedagnkighmdleigoogle
5. 建立Web Server和File watch server, 腳本以下保存爲e:\WebSite\server.jsspa
var connect = require('connect'); var serveStatic = require('serve-static'); var app = connect(); app.use(serveStatic(__dirname + "\\WebSite")); app.listen(5000); console.log('Web Server start') livereload = require('livereload'); server = livereload.createServer(); server.watch(__dirname + "\\WebSite"); console.log('File watching start')
6. 運行server.js
e:\WebSite>node server.js
這樣只要e:\WebSite下的文件一更新,瀏覽器打開的頁面就會自動刷新