项目发布了,总算可以小小地空闲一下了,看到 node.js 最近比较火,决定试试!

1. 去 node.js 的官网 下载安装文件,我下载的是 Windows 平台的 node-v0.10.4-x86.msi

2. 安装过程中基本上都是下一步下一步,直到完毕。

3. 在 C 盘新建一个记事本文件,重命名为 example.js  ,名称可以随便起。

4. 贴下如下脚本:

var http = require('http');
http.createServer(function (req, res) 
{
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World!我的英文名叫bruce,我非常热爱编程,哈哈!\n');
}).listen(1337, '127.0.0.1');

console.log('Server running at http://127.0.0.1:1337/');

5. 打开 开始 => 所有程序 => Node.js => Node.js Command Prompt

6. 进入 C 盘根目录,“编译” 我们的 example.js ,命令为:node example.js

初试 node.js 【一】

7. 不要关闭这个“Node.js Command Prompt” 窗口。打开浏览器,输入 http://localhost:1337/

8. 运行效果如下:

初试 node.js 【一】

谢谢浏览!

相关文章:

  • 2021-09-16
  • 2021-12-06
  • 2021-09-25
  • 2021-09-07
  • 2022-02-20
  • 2021-09-12
猜你喜欢
  • 2022-12-23
  • 2022-02-24
  • 2021-04-23
  • 2021-06-10
  • 2021-12-14
  • 2022-12-23
  • 2021-10-29
相关资源
相似解决方案