I am trying to configure Netbeans IDE 7.4 for node-webkit development.

It is excellent IDE but I want to run my projects with F6 button. To do this I added NW.EXE as additional browser (executable is located outside project folder).

After this I have a problem with execution arguments. NW.EXE expects a folder path to be specified as an argument, but I cannot leave empty field of Start File in project settings and the Project URL has to start with either http:// or file:// while Node-webkit needs a path like C:/path_to_app

Does any method exist to deal with this feature?

有帮助吗?

解决方案

In short, you can work this around by creating a batch program and let it strip the file name down to the path name part, to be fed to nw.exe, as it requires.

Unfortunately, as you said, we don't have full control over the way the main file of the project is passed to the browser, hence some further actions (in addition to the creation of the batch file) are needed.

This is how I got it working after a bit of struggle:

  • added nw.exe to the system %PATH% variable (optional, just for ease of access)
  • created nw.bat in the same folder as nw.exe, and filled it with this content:

    @echo %1
    start nw.exe %~d1%~p1
    

The first line of this batch file is just to inspect the actual parameter that is getting passed to the batch file.

The second line uses start to invoke nw.exe without having to wait for its return (you may need to specify the full path to nw.exe, if you didn't add it to the system %PATH% variable).

The second line also passes to nw.exe the drive part of the parameter (extracted from %1 by %~d1) concatenating it to the path of the parameter (extracted from %1 by %~p1).

For instance, my last run from within NetBeans gave this output:

D:\node\test\index.html
D:\node\test>start nw.exe D:\node\test\

Then I needed something to tie the NetBeans run button to an arbitrary executable, and luckily I found a perfect fit.

So here is how I went on:

  • installed the Node.js Projects plugin from Timboudreau Update Center
  • went to Options > Miscellaneous > Node.js and set the Node.js Binary field to point to my nw.bat file

In my project, I've also taken care to put package.json in the same folder of index.html (being that that's the main file of my package, and that's what will be fed to the batch file).

Now pressing F6 on my NetBeans installation happily runs my node-webkit project without any further ado :-)

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top