1、下载安装文件
下载地址 http://www.nodejs.org/download/,选择windows版本即可。
 
2、安装
将下载的文件双击安装,默认路径是C:\Program Files(x86)\nodejs
 
3、测试
安装完成后,即可进行测试。
打开cmd,键入node,即可进入nodejs命令。键入.help,输出如下:

C:\Users\ctid>node
> .help
.break Sometimes you get stuck, this gets you out
.clear Alias for .break
.exit Exit the repl
.help Show repl options
.load Load JS from a file into the REPL session
.save Save all evaluated commands in this REPL session to a file
>

表示安装成功!

4、HelloWord

编写一个js文件,命名为HelloWorld.js,内容如下:

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

进入cmd,输入node E:\nodejs\HelloWorld.js,即可看到输出:

Server running at http://127.0.0.1:8887/

在浏览器中输入http://127.0.0.1:8887/,即可看到HelloWord字样。

 

 

 
posted on 2013-12-30 11:14  newyear821  阅读(270)  评论(0编辑  收藏  举报