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

猜你喜欢

转载自blog.csdn.net/plpldog/article/details/80800040