node.js - 如何在 netbeans 中运行 node.js 文件?

标签 node.js netbeans

在 net beans 中我安装了 node.js pulgin。但是我的示例 Node 程序不工作。我收到错误。 这是我的示例代码

    var http = require("http");
    http.createServer(function (req, res) {
    res.writeHead(200, {"Content-Type": "text/plain"});

    res.end("Hai! welcome to node.js...!\n");

      }).listen(3030, "localhost");



   console.log("Server running at http://127.0.0.1:3030/");/* 

在运行上面的程序时,出现以下错误。

                  module.js:340
                 throw err;
                     ^
         Error: Cannot find module 'C:\Program Files\NetBeans 7.0.1\hello.js'
        at Function.Module._resolveFilename (module.js:338:15)
        at Function.Module._load (module.js:280:25)
        at Function.Module.runMain (module.js:497:10)
        at startup (node.js:119:16)
        at node.js:903:3

但是上面的程序可以在终端运行。

最佳答案

据我所知,目前有 2 个用于 Node.js 的 netbeans 插件

您正在使用的那个 http://plugins.netbeans.org/plugin/36653/nodejs

(非常简单的插件,它做的不多(我在旧版本的 netbeans 上使用它),我无法让它在 netbeans 7.4 上工作)

还有第二个:

NetBeans NodeJS 插件 https://github.com/timboudreau/nb-nodejs

我想建议你切换到第二个,因为:

  • 它确实有效
  • 它提供了一个“Node 项目类型”
  • 更多

关于node.js - 如何在 netbeans 中运行 node.js 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15382509/

相关文章:

node.js - 这在 NodeJS 中是未定义的

node.js - 未处理的PromiseRejection警告: Insufficient funds

tomcat - 严重 : Exception sending context initialized event to listener

java - EJB异常,可能是什么原因造成的?注解?服务器 :GlassFish

java - 如何在netbeans中自定义swing UI设计

java - 如何给JButton设置图像图标?

javascript - Adm Zip - 文件压缩为文件夹

javascript - 不同域之间共享数据

node.js - Express 如何路由相似的 url 链接?

java - 如何正确安装mysqlconnecter java?