[转载]nodejs终于支持windows了:windows版的node.js简单示例

一大早看到微博上有大牛说node官方发布了Windows版的nodejs,赶紧抓下来看看,虽然是unstable版本的,但起码向Windows走来,必定会推动node的发展,太好了。

1、下载node.exe放到任意目录,假设E:\nodejs\

2、在E:\nodejs\下新建helloworld.js,输入以下内容,保存关闭

 var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World\n');
}).listen(1337, "127.0.0.1");
console.log('Server running at http://127.0.0.1:1337/');

 

3、运行cmd,cd到E:\nodejs\下,输入:node helloworld.js

ps:您也可以直接将helloworld.js拖放到node.exe上运行



4、打开ie,运行http://127.0.0.1:1337/

恩,收工。简单吧,其实这是官网的demo,更多例子参考官方文档吧。

 项目主页:http://nodejs.org/

windows版地址:http://nodejs.org/dist/v0.5.1/node.exe

官方doc:http://nodejs.org/docs/v0.5.1/

node介绍:http://radar.oreilly.com/2011/07/what-is-node.html

posted @ 2011-07-18 09:43  在北落  阅读(2534)  评论(1)    收藏  举报