nodejs热部署——hotnode

1.先安装hotnode插件

npm install -g hotnode

(淘宝镜像cnpm install -g hotnode

2.部署express的web项目

var express = require('express');
var app = express();
 
app.get('/', function (req, res) {
	console.log("==========hello")
   res.send('Hello World');
})
 
var server = app.listen(8081, function () {
 
  var host = server.address().address
  var port = server.address().port
 
  console.log("应用实例,访问地址为 http://%s:%s", host, port)
 
})
3.访问地址:http://127.0.0.1:8081/

输出:

D:\mynodejs>hotnode server.js
    hotnode  node process restarted
应用实例,访问地址为 http://:::8081
(node:4536) DeprecationWarning: util.print is deprecated. Use console.log instead.
==========hello

4.修改server.js

var express = require('express');
var app = express();
 
app.get('/', function (req, res) {
	console.log("==========hellohello")
   res.send('Hello World');
})
 
var server = app.listen(8081, function () {
 
  var host = server.address().address
  var port = server.address().port
 
  console.log("应用实例,访问地址为 http://%s:%s", host, port)
 
})
5.再次访问 3: http://127.0.0.1:8081/

输出:nodejs热部署——hotnode_第1张图片


你可能感兴趣的:(nodejs热部署——hotnode)