NodeJS - plugin detail

Node.js support in Netbeans IDE. Node.js installation is required, you can edit execution command in options/miscellaneous/Node.js. On windows you will see a bubble notification in the right left corner which says plugin reconfigured cmd in options for running node on win. Then you can run again with expected results.

you can kill all node instances before starting new instance to be sure that only one process is running ..that means every new run will explicitly kill previous node run if exists.. for that purpose use this config for default run command:
#default run command:

echo 'killing running node if exists';
pkill node;

cd ${workingdir};
echo 'run node project @' && pwd;

/usr/local/bin/node ${selectedfile};
#################

Here please, to note that I have node installed to be run @ /usr/local/bin/node .. it may differ from your node path. so change it if its necessary.

RE:RE:How to stop the server

RE: How to stop the server

Ver 2.2 is not stopping the node instances. In fact it is creating more node processes.
ps aux is showing:
S 21:02 0:00 /bin/sh -c cd ${workingdir};?node ${selectedfile};
Sl 21:02 0:00 node
for each time I clicked stop all running instances (I'm impatient, there were several).
For those wondering S = interruptible sleep (waiting for an event to complete) and l = is multi-threaded.

Cannot Stop the server

I can't seem to figure out how to stop the server. I can run with node.js fine but if I want to make a change I assume I have to stop the server save changes and run again and I can't find an option to stop the server.

This is probably obvious but, I can't seem to find it so any help would be appreciated.
(Similar question was asked before but there was no reply from NETBEANS COMMUNITY)

RE: mrosefelt

Could you please just click the button "Reset for windows" on the plugin options? If you have correctly installed node.js there is no need to configure anything. Alias for node is "node", change dir is just setting current dir to look for ${selectedfile}, when you click on the "Reset for windows" it will cd to the ${workingdir}. Like this: "cd ${workingdir} && node ${selectedfile}"

How to change the execution dir?

I'm not able to get this plugin to change to the correct directory to execute my script.
I have node.js and your plugin installed. I've set the Tools/Options/Miscellaneous/NodeJS path to the directory which contains the file that I am testing, but that directory is not being used, so executing file "jsTester01.js" produces this error:
module.js:340
throw err;
^
Error: Cannot find module 'C:\Program Files\NetBeans 7.3.1\jsTester01.js'
NB 7.3.1 on Win7 x64
I did restart NB after setting the option to:
cd "D:\Artstuff\MiscWebStuff\html samples" && node ${selectedfile}
Thanks.

RE: Support for NetBeans 7.3?

Thank you, Daniel. I tried installing the 7.2 version. The installation appears to have been successful, but either I don't understand how to use the plugin or it isn't working.

I tried to create a Node.js project, but the New > Project menu didn't have a Node.js option, so I created an HTML/JavaScript project. I added a Hello World program in a file named index.js. The context menu for adding a file from the Project pane did not have a Node.js option either, although it had two options named JavaScript, which might have been due to an unsuccessful attempt to add a Node.js file type.

With index.js open and selected, I executed the Run > Run command. It opened a dialog that said I have to install a Chrome extension, which makes me believe that it was trying to run the file as a JavaScript file rather than a Node.js file.

RE: Support for NetBeans 7.3?

Support for NetBeans 7.3?

I'm running NetBeans 7.3.1 under Windows 7. The plugin manager doesn't list your product, and the tabs on the manual download page only go up to 7.2. Do you have plans to support 7.3.x in the near future?

Stop node server

I can't seem to figure out how to stop the server. I can run with node.js fine but if I want to make a change I assume I have to stop the server save changes and run again and I can't find an option to stop the server.

This is probably obvious but, I can't seem to find it so any help would be appreciated.

Thanks

RE: systemovich

Untrusted is the certificate of our company probably because it has expired long ago, that's all. You can check if the company is real here:
https://or.justice.cz/ias/ui/vypis-vypis?subjektId=isor%3a100009408&typ=full&klic=1bvl6y

Untrusted

RE: fra.casula

This plugin doesn't add support for the project type, so there is no reason to say "it soesnt work". If you read description above it says clearly :"In NetBeans IDE execute selected javascript file with editable command. Default command is node /blah/blah/some.js."

doesn't work with netbeans 7.2

I've downloaded netbeans 7.2 full version linux x64...
I've found this plugin in Tools => Plugins => Available Plugins but after installation there is no Node.js support and no project type for node.js

Thanks

RE: jhermsen

Well you are using undocumented part of the Grunt API,
if you read comment in the source code: "This is only executed when run via command line.",
you probably should look for the methods wich are specifically calling tasks.
Cli function takes as the second argument async function which
is executed when build is done instead of "process.exit(0);".
On Linux it doesn't matter but on win is causing that process invoked externally
doesnt flush output in time. So on windows calling method cli should look like this:
"grunt.cli({},function(){});"
Then even the JVM can catch your output, because process.exit is not called.
To fix your code call grunt like this:
"require('grunt').cli({},function(){});"

RE: jhermsen

I know what binary is but that is what netbeans tells me.
If I run a basic nodejs file with only console.log command and redirect to file there is no message opening the file.
If I use grunt like I showed below which does work actions are performed so node grunt.js command works, but the output is not shown in the output window.
If I then redirect the output to file and open it in netbeans I get the message:
This file appears to contain binary data. Are you sure you want to open it in the text editor?
And the file contains all data, so why doesn't it visible in the output window if I run it without redirect?

Becuase I call the grunt module cli it works with "node grunt.js" also from commandline showing me the output as expected. Just not in your plugin.

Hope you can help on this, because I'd like to call it from netbeans and see results there.

RE:jhermsen

I am convinced that you do not know what the word "binary" means.
Anyway I have a limited awareness of grunt but I do not think that you use it properly. File grunt.js of Grunt build tool is equivalent to build.xml file of the Ant. If you want to build your project, you have to run grunt command from the command line in the folder where the file grunt.js is present. So running "node grunt.js" is useless, instead run just "grunt".
I wish you good luck with grunt
Daniel

It works perfectly on Windows

Just change the command from cd ${workingdir} && node ${selectedfile} to node ${workingdir}\${selectedfile}, of course node should be on the path, remember Windows path variable and dir commands. I'm using Windows 7 Enterprise and netBeans 7.1.2 but I think it doesn't matter.

Cannot run program "npm"

Hi!

When i try "Add Library" result ide:

java.io.IOException: Cannot run program "npm": error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:460)
at org.netbeans.modules.nodejs.libraries.LibrariesPanel.run(LibrariesPanel.java:240)
at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1452)
at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2032)
java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.forkAndExec(UNIXProcess.java:0)
at java.lang.UNIXProcess.(UNIXProcess.java:53)
at java.lang.ProcessImpl.start(ProcessImpl.java:91)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:453)
at org.netbeans.modules.nodejs.libraries.LibrariesPanel.run(LibrariesPanel.java:240)
at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1452)
at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2032)

Nice

now it is available for windows

What about daemons?

The way this plugin waits for process.waitFor in cz.kec.nb.nodejs.RunNode.performAction makes impossible to use the plugin with long processes, like HTTP server. So I hacked the sources given by Danielkec, and now it prints the output of the node in a separate thread: http://andskiba.blogspot.com/2011/09/nodejs-plugin-for-netbeans-and-daemons.html

Why not on windows?

Source is available

Just mention Syntea software group in the description of the plugin if you use them please. If you can use some help with your plugin contact me on daniel[at]kecovi.cz i will be pleased to join you.
srcs: http://www.syntea.cz/netbeans-modules/nbjs/NodeJS.tar.7z