Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot debug Nodejs with node-inspector: websocket_closed and Assertion failed: Unknown experiment canvasInspection

I try to debug my server.js app with node-inspector (v0.12.8), nodejs (v5.9.1) and chrome (v49.0.2623.112 m) under windows environment.
In a shell i do

node-inspector   
Node Inspector v0.12.8 Visit http://127.0.0.1:8080/?port=5858 to start debugging.

In a second shell i do

node --debug server.js

When i go to chrome tab i obtain a message:

Detached from target
remote debug has been terminated with reason: websocket_closed
please reattach to the new target

In the console dev tool of chrome i can see either a message that inspector can't find experimental function canvasInspection (removed in the latest chrome version).
I'm doing something wrong?

like image 882
ThePrestige Avatar asked Apr 12 '16 06:04

ThePrestige


People also ask

How do I debug Node JS in Chrome?

Using Google Chrome DevTools to Debug To start debugging, let's run our application with the --inspect-brk flag. The next step is to head to Chrome, open a new tab, and enter the URL chrome://inspect/ . Click on “Open dedicated DevTools for Node” to start debugging the application.

How do I debug node js app?

Open the starting file (typically index. js ), activate the Run and Debug pane, and click the Run and Debug Node. js (F5) button. The debugging screen is similar to Chrome DevTools with a Variables, Watch, Call stack, Loaded scripts, and Breakpoints list.

Which of the following commands is used to install Node inspector via NPM?

The node-debug command will load Node Inspector in your default browser. NOTE: Node Inspector works in Chrome and Opera only.


1 Answers

I had the same problem, I fixed it the way below:

1- Go and edit the following file in your currently in use nodejs path:

 ...\node_modules\node-inspector\lib\InjectorClient.js

2- Go to line 111. if you're using vim as text editor you can do it by command :111

3- Add the following if statement at line 111 and indent the next line.

if(NM.length > 0) 
  cb(error, NM[0].ref);

4- Save and re-run node-inspector.

Cheers!

I'm using MacOS Sierra, Node v6.3.1. But the solution is general.

like image 76
Kasra Avatar answered Oct 06 '22 23:10

Kasra