您的位置:首页 > Web前端 > Node.js

NodeJS For Windows

2012-03-02 15:13 507 查看

概述

NodeJS是一个Javascript运行环境(runtime)。它是对V8引擎的封装。它采用了“事件循环”架构,并使用非阻塞库支持此架构。它适用于数据敏感、实时性网络应用程序。

相关信息请猛击此处: http://nodejs.org/

NodeJS在github上的地址:https://github.com/joyent/node

安装

如果源码安装,请安装如下依赖:

l Python – version 2.6 / 2.7

l Libssl-dev – 如果你计划使用SSL/TLS加密,你需要安装这个。

Windows

需要python和Microsoft Visual Studio,但不需要OpenSSL。在cmd.exe中做如下操作:

我安装了python-2.6.6,下载地址为:http://www.python.org/getit/releases/2.6.6/

Tar工具的下载地址为:http://gnuwin32.sourceforge.net/packages/gtar.htm

VS要求是2010。。。。。

C:\Users\ryan>tar -zxf node-v0.6.5.tar.gz

C:\Users\ryan>cd node-v0.6.5

C:\Users\ryan\node-v0.6.5>vcbuild.bat release

[Wait 20 minutes]

C:\Users\ryan\node-v0.6.5>Release\node.exe

> process.versions

{ node: '0.6.5',

v8: '3.6.6.11',

ares: '1.7.5-DEV',

uv: '0.6',

openssl: '0.9.8r' }

>


看到以上信息后,说明成功安装。

0.6以上的版本中包含了npm,所以,不需要单独安装。

验证

在成功build完nodejs后,让我们运行下helloworld.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(8124);

console.log('Server running at ' target='_blank'>http://127.0.0.1:8124/');[/code] 
打开cmd,当前目录为node.exe所在目录,执行下面命令:

node helloworld.js


然后,在浏览器中输入地址:http://127.0.0.1:8124/。页面内容为Hello World。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: