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 中文學習資料和教程導航

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM