** 在 Intellij IDEA 中安裝 node plugins**
打開“文件”菜單,選擇“設(shè)置”,選擇"Plugins",輸入"nodeJS",再點(diǎn)擊安裝即可。

nodejs-1.png
** 安裝 nodejs**
去中文官文網(wǎng)站: http://nodejs.cn/download/ 下載安裝文件。
下載后點(diǎn)擊執(zhí)行文件即可完成安裝。

nodejs-3.png
** Intellij IDEA配置**
先在webapp目錄寫一個(gè)啟動(dòng)文件helloworld.js:
var http = require("http");
http.createServer(function(request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.write("Hello World");
response.end();
}).listen(8888);
console.log("nodejs start listen 8888 port!");
Intellij IDEA配置NodeJS
打開“Edit configurations”,進(jìn)入配置面板

nodejs-4.png
點(diǎn)擊“+”,選擇Node.js,這兒有幾項(xiàng)需要填,分別是:
- name: web-nodejs,你需要啟動(dòng)服務(wù)的名稱
- Node interpreter: [your_node_path]\node.exe 選擇你本的node執(zhí)行文件路徑
- node parameters: helloworld.js 監(jiān)聽腳本
-
Working directory: [your_website_path]\myapp 你本地app的存放路徑
點(diǎn)擊運(yùn)行
nodejs-6.png
打開瀏覽器,查看運(yùn)行結(jié)果
nodejs-7.png

