1

I wrote a simple script:

var a = 7;
var b = a + 2;
var c = b;

I put the above script in a file foo.js.

Now I open Git Bash in the same with foo.js folder and run the following command:

node --inspect foo.js

Here is what I am getting:

$ node --inspect foo.js

Debugger listening on ws://127.0.0.1:9229/185f8862-17db-44d5-aff0-03c8e6fd50df

For help, see: https://nodejs.org/en/docs/inspector

Then I go to chrome://inspect/, then to Open dedicated DevTools for Node.

Here is what I see: enter image description here

I do not see my code for run or debug. What am I missing here?

Thank you.

1
  • I am unable to reproduce your case, but since it seems like you are using Visual Code, I recommend you to use the in build Node.js debugger. Here are the steps to follow in order to configure it code.visualstudio.com/docs/nodejs/nodejs-debugging. Newer version of Visual Code will automatically configure the debugger and you just have to set the breakpoints and press the debugger button or F5, keep in mind that it will create a launch.json in your root project folder .vscode>launch.json Commented Mar 18, 2019 at 21:46

3 Answers 3

1
  1. node --inspect-brk foo.js.
  2. Move to Chrome and enter chrome://inspect in the tab
  3. Move to device-->Remote Target-->foo.js-->Click inspect
  4. In the new window, on the left tab, click Add folder to Workspace and select the folder containing the file foo.js

Now you can debug the file.

Sign up to request clarification or add additional context in comments.

Comments

0

Look closely at protocol. It's not a http connection (which you're connecting on) but WebSocket. This is mostly for IDEs to handle debugging such as VSCode.

Btw. VSCode has native support for debugging Node.js, just write some app and press F5

Comments

0

Try to open inspector tools, instead, from "Remote Target" section from this page:

chrome://inspect/#devices
  • Old way yet also available - open tab with url:
chrome-devtools://devtools/bundled/inspector.html?experiments=true&v8only=true&ws=127.0.0.1:9229/{{YOUR_KEY}}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.