如何在intelliji idea中集成nodejs

** 在 Intellij IDEA 中安装 node plugins**

打开“文件”菜单,选择“设置”,选择"Plugins",输入"nodeJS",再点击安装即可。


nodejs-1.png

** 安装 nodejs**

去中文官文网站: http://nodejs.cn/download/ 下载安装文件。
下载后点击执行文件即可完成安装。

nodejs-3.png

** Intellij IDEA配置**

先在webapp目录写一个启动文件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”,进入配置面板


nodejs-4.png

点击“+”,选择Node.js,这儿有几项需要填,分别是:

  • name: web-nodejs,你需要启动服务的名称
  • Node interpreter: [your_node_path]\node.exe 选择你本的node执行文件路径
  • node parameters: helloworld.js 监听脚本
  • Working directory: [your_website_path]\myapp 你本地app的存放路径
    点击运行


    nodejs-6.png

    打开浏览器,查看运行结果


    nodejs-7.png
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容