How To Run / Debug Node.js Application With Eclipse

Eclipse is the most popular programming IDE. It can be used to develop java application as well as JavaScript application. In this article we will introduce how to use Eclipse to create / debug node.js application.

1. Create JavaScript Project.

  1. Install JDK and Eclipse IDE in your windows PC. If you do not know how to do, please read article Beginner’s Guide For Install Jdk(Java Delvelopment Kit) And Eclipse In Windows.
  2. If you use Eclipse Neon version 3, then click File —> New —> Project menu. Choose JavaScript Project in New Project popup dialog.
    create new javascript project in eclipse
  3. Click Next button, input project name and select workspace, click Finish button to create the JavaScript project successfully.
    input javascript project name and select workspace

2. Create JavaScript File.

  1. Right click JavaScript project name in left project explorer panel. Click New —> Other… menu. In the popup dialog, choose JavaScript —> JavaScript Source File as below. Click Next button to continue.
    create javascript source file in eclipse
  2. Select saved folder and input JavaScript file name in next dialog then click Finish button.
    input javascript file name
  3. Now you can see test.js in left project explorer.

3. Setup Debug Runtime Configuration.

Before you can debug your JavaScript file, you must first create a debug configuration follow below steps.

  1. Click Eclipse tool bar Window —> Preferences menu.
    click window preferences menu
  2. Click JavaScript —> Runtimes menu in left panel. Choose Node.js Runtime in right JavaScript Runtimes dropdown list. If you do not have exist installed node runtime installation, you can click Add button to add one.
    create node.js runtime environment in eclipse window preferences
  3. Click Add button to add node.js runtime environment. This need you first install node.js in your PC. You can read article How To Install Node JS In Windows to learn more. I recommend you install node.js windows binary edition which is unzipped from a zip file.
  4. In the Add JavaScript Runtime Install dialog, select node.exe from your install directory to the location input box, give it a name in second input box, input node start arguments in the third input box if you have.
    create node javascript runtime install
  5. Click Finish button, it will return back to the Runtimes list page. Check the checkbox before the JavaScript runtime that you want to use and click OK.
  6. I recommend you use node version 7.10.1, because it is a more stable version, if you use version 8 or 9, when you start debugging, it maybe through below error message.
    (node:10012) [DEP0062] DeprecationWarning: `node –debug` and `node –debug-brk` are invalid. Please use `node –inspect` or `node –inspect-brk` instead.Failed to connect to Standalone V8 VM
READ :   Node JS EventEmitter Example

4. Debug JavaScript File.

  1. Write some JavaScript code in test.js file. Double click the first column of each code line to set breakpoint.
  2. Right click the js file in left panel, choose Debug As —> Debug Configurations menu. It will popup a dialog which let you configure debug parameters.
    configure debug parameters
  3. After change debug parameters or just use the default value, click Debug button at dialog bottom. Click Yes button in Confirm Perspective Switch dialog then the code execution will stop at the first line of JavaScript file. Then you can click step into ( means run into current function ), step over ( execute over current function without go into it ), step out ( go out of current JavaScript function if you run into it just now) debug menus in Eclipse top toolbar to debug your JavaScript file.
    debug javascript file toolbar menu

5. Notes.

I just test above procedure with Eclipse Neon.3 Release ( 4.6.3 ) and node version 7.10.1. These two component are stable to use.

  1. Eclipse Neon 3 Packages
  2. Node.js 7.10.1

If you use Node.js version 8 or 9, then you may encounter debug start failed error with below error message.

(node:10012) [DEP0062] DeprecationWarning: `node –debug` and `node –debug-brk` are invalid. Please use `node –inspect` or `node –inspect-brk` instead.

Failed to connect to Standalone V8 VM

7 Comments


  1. Thank you for the post!

    But I had a problem starting Eclipse Neon.3 + Java 10 SDK (W10 64)…
    The solution was change the file eclipse.ini this way:
    –launcher.appendVmargs
    -vm
    C:\Program Files\Java\jdk-10.0.1\bin\javaw.exe
    -vmargs
    -Dosgi.requiredJavaVersion=1.8
    –add-modules=ALL-SYSTEM

    Reply

    1. I encountered the error stated above. ((node:12884) [DEP0062] DeprecationWarning: `node –debug` and `node –debug-brk` are invalid. Please use `node –inspect` or `node –inspect-brk` instead.

      Failed to connect to Standalone V8 VM).

      Is anyone able to help me rectify this error? I have been stuck on this for a few days. Kindly assist.

      Thank you.

      Reply

    2. @DRinaldin.

      Kindly explain step by step how to do that.

      Thanks

      Reply

  2. If you use Node.js version 8 or 9, then you may encounter debug start failed error

    But I need to debug with v.9. Is there any possible ?

    Reply

  3. Good Work Sir ,my Code fine to work
    my first program using node js .
    thank you…

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.