1.HelloWorld.js
console.log("HelloWorld")
2.server.js
var http = require('http'); http.createServer(function(req,res){ res.writeHead(200,{'Content-Type':'text/html'}); res.write('<h1>Http Server changed</h1>'); res.write('<p>安裝supervisor的命令sudo npm install -g supervisor</p>'); res.end('<p>By JimLi</p>'); }).listen(5858);
3.supervisor的安裝與運行
sudo npm install -g supervisor
運行方法:supervisor app.js
4.node的一些命令
命令 | 功能 |
---|---|
node -v |
查看版本 |
node -e eval script |
e后面直接跟javascript代碼,直接運行 |
node app.js |
運行node.js的代碼 |