Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't get node-debug to work

This feels really silly, but I can't get node inspector / node-debug to work.

The instructions say to do npm install then to run node-debug web.js. So I did that. Now I have a lovely browser window open showing me my code with breakpoints... and no idea which url to use to actually access the code.

The inspector is at http://localhost:8080/debug?port=5858 and the terminal says:

> node-debug web.js
debugger listening on port 5858
Node Inspector is now available from http://localhost:8080/debug?port=5858
Debugging `web.js`

...

I've tried hitting up localhost:5000 (which is my express.js port) but that either fails if I don't have a separate node web.js instance running, or it succeeds if I have the other one running but doesn't trip any of the breakpoints in the inspector.

When I go to http://localhost:5858/, I get:

Remote debugging session already active

When I go to http://localhost:8080/, I get:

Cannot GET /

(the / path totally works on my server in general.)

like image 799
MalcolmOcean Avatar asked May 02 '14 21:05

MalcolmOcean


People also ask

How do I debug a Node JS program?

Attach: Attach to the debug port of a locally running Node.js program. Make sure that the Node.js program to debug has been started in debug mode, and the debug port used is the same as the one specified in the snippet. Attach to Remote Program: Attach to the debug port of a Node.js program running on the host specified by the address attribute.

How to run vs code debugger in nodemon?

If you have started your program server.js via nodemon on the command line like this: you can attach the VS Code debugger to it with the following launch configuration: Alternatively you can start your program server.js via nodemon directly with a launch config and attach the VS Code debugger:

How does the node debug adapter handle source maps?

First, a quick explanation of how the Node debug adapter handles source maps. When you set a breakpoint in app.ts, the debug adapter has to figure out the path to app.js, the transpiled version of your TypeScript file, which is what is actually running in Node. But, there is not a straightforward way to figure this out starting from the .ts file.

How do I stop a debug session in Node JS?

Using the Debug: Stop action (available in the Debug toolbar or via the Command Palette) stops the debug session. If the debug session was started in "attach" mode (and the red terminate button in the Debug toolbar shows a superimposed "plug"), pressing Stop disconnects the Node.js debugger from the debuggee that then continues execution.


1 Answers

By default node-debug starts app in --debug-brk mode. This stops your app at first line (express not started).

You can use node-debug --no-debug-brk see the node-debug --h for more info.

like image 110
3y3 Avatar answered Sep 22 '22 12:09

3y3