nodejs-helloword案例

确认正确看着了node

本例处理环境win10

创建文件helloword.js。如下图:存放位置

具体内容详细

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

cmd命令找到js文件,执行node命令

node helloword.js

如下图:

上图介绍:

1.进入文件存放目录里

2.执行node命令,发布js

3.编译出现异常(来的突然没预料的到)

4.修改文件正确继续编译

5.浏览器请求地址查看输出

原文地址:https://www.cnblogs.com/hwaggLee/p/5233951.html