官网描述:
Node.js is a platform built on Chrome's JavaScript runtime for easily building fast, scalable network applications.
Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient,
perfect for data-intensive real-time applications that run across distributed devices.
(译)Node.js 是一个平台,建立在 Chrome JavaScript 运行时之上,为了更容易建立快速、可伸缩的网络应用。
Node.js使用事件驱动,非阻塞的 I/O 模式,这使得他是轻量而高效的,能够在分布设备上完美运行高数据吞吐的实时应用。
安装测试:
打开cmd命令窗口,输入node,回车;
cmd窗口会出现”>”输入".help”,回车;
> .help .break Sometimes you get stuck, this gets you out
.clear Break, and also clear the local context
.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
恭喜您基本安装成功! 开始一个HelloWorld:
在D盘建立一个文件夹:Nodejs
在些文件夹下新建一个文本文件,并输入
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 http://127.0.0.1:8124/');
保存,并重命名文件为"HelloWorld.js”;
打开cmd命令窗口:
D:\Nodejs>node HelloWorld.js 回车; Server running at http://127.0.0.1:8124/
在本地浏览器地址中,输入:http://127.0.0.1:8124/,OK,欢迎进入Node.js世界; 提示:在命令窗口下,按Ctrl+Break可结束刚启动HelloWorld--Web服务;