node.js

因为最近对node.js感兴趣,

 

1: 安装node.js 去官网下载最新的mis包,win7下

 

2: 在cmd下运行node -v 查看安装的版本

 

3: http://www.nodebeginner.org/index-zh-cn.html#javascript-and-nodejs

node.js入门的书籍;

 

安装sub lime text3 写js脚本;以前听过很多人推荐;现在自己用起来感觉真是不错,什么都能干;

  1: 安装pachkage control 插件 

  2: 安装 SublimeCodeIntel 提示插件

 

node.js入门例子: 新建一个sever.js

 

var http = require("http");
var url = require("url");

function start(){
	function onRequest(request, response){
		var path = url.parse(request.url);
		console.log("path = "+path.pathname);
		console.log("receive request");
		response.writeHead(200, {"Content-Type": "text/plain"});
		response.write("http sever start");
		response.end();
	}

	http.createServer(onRequest).listen(8080);

}

exports.start = start;

 

 新建一个index.js

  

var sever = require("./sever");

sever.start();

 

在cmd中进入目录下 node index.js

 

访问: http://localhost:8080

你可能感兴趣的:(node.js)