Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run the node.js file in net beans?

In net beans i have installed node.js pulgin.But my sample node program is not working.Im getting error. This is my sample code

    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/");/* 

While running the above program.Im getting following error.

                  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

But the above program works from the terminal.

like image 834
Aarthi Chandrasekaran Avatar asked Mar 13 '13 10:03

Aarthi Chandrasekaran


2 Answers

From my knowledge, currently there are 2 netbeans plugins for Node.js

The one you're using http://plugins.netbeans.org/plugin/36653/nodejs

(very simple plugin, it doesn't do much (I used it on an older version of netbeans), and I can't get it to work on netbeans 7.4)

and a second one:

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

I want to suggest that you switch to the second one, because:

  • it actually works
  • it provides a "node project type"
  • more
like image 127
Nahn Avatar answered Oct 29 '22 20:10

Nahn


Netbeans Node support does not appear quite ready for prime time. Problem: the "standard" (danielkec) Node plugin does not know about projects, so you will have to create a bogus (Html5??) project to use it. Problem2: Tim Boudreau's Node plugin does nicely with project creation and code completion but it has zero support for debugging (Tim prefers inserting print statements in the code). So at this point (Netbeans 8), I would not recommend Netbeans for Node.js work.

like image 21
user2104493 Avatar answered Oct 29 '22 19:10

user2104493