D:\workspaces\Nodeclispe-DEV\nodeclipse-1\org.nodeclipse.help\contents\.run.md.html

Title: Nodeclipse Online Help - Run

## Running

Right-click `.js` file with Node.js app and select "Run As -> Node Application" (similar to Java applications).

Press `Ctrl+F11` to run [again].

### Running issues

- #72 All nodejs apps fail to run (JDK 6 only?) is related to Eclipse and Java version that you use, so updating them would solve. Quote bjm88:

  Ok working now for me. It does seem you have to uninstall nodeclipse then do Java 7 update ( i tried jre 64 bit and jdk 32 bit, both ok), and set that new java 7 in your eclipse.ini file (format is important). Then reinstall nodeclipse and it will work. Example eclipse.ini entry: -vm C:/dev/java7/bin/javaw.exe -vmargs -Xms128m -Xmx1024m

- #107 Failed to connect to Standalone V8 VM even on JDK 1.6.0_30 was solved by running `node --debug-brk app.js` first. Quote haroldjiang:

  yes,the solution is to run node --debug-brk app.js first.

see also Debug page.

### Run Configuration

You can configure node and apps parameters workspace wide in `Preferences -> Nodeclipse` or per file:

Right-click `.js` file with Node.js app and select "Run As -> Run Configuration..." (Hint: the easiest way to create LaunchConfiguration is actually run the file once.)

You can configure to pass

- program arguments
- Node arguments
- set working directory

To have LaunchConfiguration saved within Project folder, select path in `Shared File` field on `Common` Tab of LaunchConfiguration. (Yes, dialog string is confusing)

Since Nodeclipse 0.5 it is possible to set environment variables in a launch configuration. The "Environment" tab is not there in the Node launcher.

As an alternative way you can also add another JS file that sets the variables before it calls the node app and run that instead.

e.g.

    setTimeout(function(){
      process.env.NODE_ENV="development";
      require("./app.js");
    },100);

### Warning multiple launch configurations

In Nodeclipse version 0.6 add possibility to run Node.js app with monitor (see Monitor page) or launch coffee util to compile `*.coffee` files. However these have ran into problem http://stackoverflow.com/questions/19157302/eclipse-plugin-development-saved-launchconfiguration-overrides-launchtype

### Restart

##### Option 1. Right-click on launched application in Debug View and select `Terminate and Relaunch`.

(In Node perspective Debug View is visible by default)

##### Option 2 by igor:

1. Right-click on your project in Project Explorer > Properties > Builders
2. New... > Program > OK
3. Name: Terminate existing node.js process(es)
4. Location: C:\Windows\System32\taskkill.exe (${env_var:SystemRoot}\System32\taskkill.exe did not work for me, it might for you)
5. Working Directory: Browse Workspace... > select your project > OK
6. Arguments: /IM node.exe /F
7. Switch to Build Options tab and tick During auto builds, untick Launch in background > OK
8. Create another builder: New... > Program > OK
9. Name: Start <your-project-name>
10. Location: C:\Program Files\nodejs\node.exe (you can try ${env_var:ProgramFiles}\nodejs\node.exe as well)
11. Working directory: same as point #5
12. Arguments: app.js (or any other file for application entry point)
13. Switch to Build Options tab and tick both During auto builds and Launch in background > OK
14. Turn on project autobuild: Window > Preferences > General > Workspace, tick Build automatically > OK
15. Change default build order: Window > Preferences > General > Workspace > Build Order, untick Use default build order and remove all projects except your node.js project > OK
16. Restart Aptana/Eclipse (There are bugs, so sometimes preference changes are just not saved and get lost. You have to double-check.)

##### Option 3 #57 running app.js with node-dev, forever, supervisor, nodemon etc

A general approach was selected #57, however as I don't [yet] use any of Node.js module named above, some polishing is needed for this functionality, like #118 The use case "Nodeclipse with nodemon"

Start talking if you care.

### Sources

Check LaunchConfigurationDelegate.java for launching Node.js logic.

### Contribute

Edit online on GitHub