如何在intelliji idea中集成nodejs

** 在 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
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容