1.http://nodejs.org/网址上点击install
2.安装下来的node-v0.10.21-x86.msi
3.配置环境变量, 把安装目录配置到path里
4.创建hello.js并写入以下内容
var http = require("http");
console.log(http);
http.createServer(function(request, response) {
response.writeHead(200, {"Content-Type": "text/html"});
response.write("Hello World!");
response.end();
}).listen(8000);
5.然后进入到hello.js文件目录下执行命令: node hello.js
6.在浏览器中http://localhost:8000/
可以看到页面打印出Hello World!
NodeJS之HelloWorld
最新推荐文章于 2024-05-17 22:10:36 发布
本文将指导您如何使用Node.js快速搭建一个简单的Web服务器,包括安装Node.js、配置环境变量、编写基本的HTTP服务器代码,并通过命令行运行服务器。
344

被折叠的 条评论
为什么被折叠?



