After long hours of googling and testing I did succeed debugging ClearScript code using node-inspector.
First of all, the latest version (0.12.3) has many extensions for debugging node.js scripts so I used an older version (0.5.0) which has less liability to node.js.
This is advised by the author of node-inspector in the following stackoverflow thread:
http://stackoverflow.com/questions/22153131/debug-v8-with-node-inspector
I used the following command to install v0.5.0.
npm install node-inspector@0.5.0
You must have node.js (
https://nodejs.org/en/) installed on your computer to run this command. Execute it in Node.js command prompt.
It is installed in folder "%USERPROFILE%\node_modules" by default.
I added one line of code to %USERPROFILE%\node_modules\node-inspector\lib\PageAgent.js:
getResourceTree: function(params, done) {
return; //return empty tree
...
This completes the installation.
Here is the guide to debug a javascript file executed by ClearScript:
Open a command prompt and execute the following command:
%USERPROFILE%\node_modules\.bin\node-inspector.cmd
You should see the following lines if node-inspector is running successfully.
Node Inspector v0.5.0
info - socket.io started
Visit
http://127.0.0.1:8080/debug?port=5858 to start debugging.
Initialize your V8 engine as in the following code line (VB):
Dim engine As New V8ScriptEngine("global", V8ScriptEngineFlags.EnableDebugging, 9222)
Put a breakpoint right after this line in your code and run your application to reach this breakpoint.
Make sure you have "debugger;" statement in the first line of your JavaScript code.
Open a Chrome browser and navigate to the following address:
http://127.0.0.1:8080/debug?port=9222
Press "Continue Debugging" button in Vİsual Studio toolbar.
Now you should see your script code stopped at the first "debugger;" line in Chrome browser.
You can continue debugging from here.
Write in this thread if you have any questions.