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.
- 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.
- If you use Eclipse Neon version 3, then click File —> New —> Project menu. Choose JavaScript Project in New Project popup dialog.
- Click Next button, input project name and select workspace, click Finish button to create the JavaScript project successfully.
2. Create JavaScript File.
- 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.
- Select saved folder and input JavaScript file name in next dialog then click Finish button.
- 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.
- Click Eclipse tool bar Window —> Preferences menu.
- 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.
- 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.
- 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.
- 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.
- 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
4. Debug JavaScript File.
- Write some JavaScript code in test.js file. Double click the first column of each code line to set breakpoint.
- 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.
- 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.
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.
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
@DRinaldin.
Kindly explain step by step how to do that.
Thanks
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.
Same issue ,
Can someone help
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 ?
You can try IntelliJ WebStorm.