春哥 发表于 2016-10-25 22:20:05

Node.js环境搭建和学习(windwos环境)

Node.js环境搭建和学习
一、环境搭建
1、下载安装文件
   下载地址http://nodejs-org.qiniudn.com/下载Node.js环境安装包,根据操作系统下载对应的安装包
   下载地址 http://www.nodejs.org/download/,选择windows版本即可。
2、安装 将下载的文件双击安装,默认路径是C:\Program Files(x86)\nodejs
3、测试 安装完成后,即可进行测试。
打开cmd,键入node,即可进入nodejs命令。
键入.help,输出如下:
C:\Users\ctid>node
> .help
.break Sometimes you get stuck, this gets you out
.clear Alias for .break
.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
>
表示安装成功!

二、测试
1、HelloWord
编写一个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(8887);
console.log('Server running at http://127.0.0.1:8887/');

进入cmd,输入node E:\nodejs\HelloWorld.js,即可看到输出:

Server running at http://127.0.0.1:8887/
在浏览器中输入http://127.0.0.1:8887/,即可看到HelloWord字样。

2.实践操作
当修改了HelloWorld.js文件内容,需要在cmd窗口下,重新输入:node E:\nodejs\HelloWorld.js,
在浏览器中输入http://127.0.0.1:8887/,才能看到修改后的效果

三、推荐几个学习网站
1、http://www.ibm.com/developerworks/cn/web/1201_wangqf_nodejs/被误解的 Node.js
2、http://www.cnblogs.com/lhb25/archive/2013/12/05/node-js-tutorials.html Node.js 中文学习资料和教程导航

页: [1]
查看完整版本: Node.js环境搭建和学习(windwos环境)