node-inspector: Detached from the target, websocket_closed, cannot read property ref of undefined (NM[0] is undefined)

Doing node-debug src/app.js

The immediate feedback from the terminal is :

Node Inspector v0.12.8
Visit http://127.0.0.1:8080/?port=5858 to start debugging.
Debugging src/app.js

Debugger listening on [::]:5858

After chrome automatically launches and tries to display the page, the chrome windows show this error message:

“Detached from the target. Remote debugging has been terminated with reason: websocket_closed. Please re-attach to the new target.”

And the console shows this error:

/usr/local/lib/node_modules/node-inspector/lib/InjectorClient.js:111
      cb(error, NM[0].ref);
                     ^

TypeError: Cannot read property 'ref' of undefined
    at InjectorClient.<anonymous> (/usr/local/lib/node_modules/node-inspector/lib/InjectorClient.js:111:22)
    at /usr/local/lib/node_modules/node-inspector/lib/DebuggerClient.js:121:7
    at Object.create.processResponse.value (/usr/local/lib/node_modules/node-inspector/lib/callback.js:23:20)
    at Debugger._processResponse (/usr/local/lib/node_modules/node-inspector/lib/debugger.js:95:21)
    at Protocol.execute (_debugger.js:121:14)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at readableAddChunk (_stream_readable.js:177:18)
    at Socket.Readable.push (_stream_readable.js:135:10)
    at TCP.onread (net.js:542:20)

I’ve searched everywhere for a solution to this problem and haven’t found one. I hope you can be of assistance!

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 121
  • Comments: 78

Most upvoted comments

Same issue with node v6.5.0 can be solved like this :

Edit …\node_modules\node-inspector\lib\InjectorClient.js file at line 111 if(NM.length > 0) cb(error, NM[0].ref);

It works

my problem can also be solved like this :

Edit …\node_modules\node-inspector\lib\InjectorClient.js file at line 111 if(NM.length > 0) cb(error, NM[0].ref);

It works well!!!

@ccqgithub @errord

Maybe node with higher version(6.9.1) built in inspect, and node-inspect don’t update longer… solution:use node --inspect yourapp replace node-inspect & node --debug yourapp It worked for me.

I think node-inspector isn’t updated anymore because node has that functionality built in now. Run node --inspect yourApp.js. This worked for me.

Ah I think this is a dup of: https://github.com/node-inspector/node-inspector/issues/905

Which seems to indicate it’s a problem with node 6.4. Workaround is to downgrade to 6.3.1.

I fixed my problem by downgrading node from 6.4 to 6.3.1. Why is this closed?

I have the same problem and I wrote the code in the line 111 of ~/node_modules/node-inspector/lib/InjectorClient.js:

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

It’s working! ❤️

Precisely the same problem I just ran into. Can find nothing.

The only information I have to add is that I used to use node-inspector successfully on node 4. I recently updated to node 6, and this is the first time I’ve tried to use node-inspector since then.

@ccqgithub Use node --inspect --debug-brk yourapp to force the app to pause and wait so you have time to copy the chrome link.

Still broken in 6.5.0!?! The downgrade to 6.3.1 makes debugging the VM work. Any idea why it’s not working, what can be done, when I/we can debug/use nodejs current version again?

Using the experimental built in node --inspect --debug app.js “Inspect” argument with node-inspector uninstalled, but with this downgrade connects but no source shown from outside of server VM? so that’s currently useless in 6.5.0 too.

Node 6.9.1 and node-inspector 0.12.8

it works following these steps: 1- open a command prompt and run the following command: node-inspector --web-port=3030 (server app port) 2- open another command prompt and run the following command: node --inspect --debug-brk server.js 3- browse to the given URL in the second command prompt log on screen 4- press F8 to make the server run 5- eventually put some others breakpoints 6- browse on another tab to your app (address and port defined in 1-) 7- see server execution stops on breakpoints defined on step 5-

@Elliott128 I have the issue with built in debugger (no code in chrome) and I haven’t remapped localhost.

How is anyone debugging Node with both of these problems???

Switching node versions constantly is not practical

same here node v6.8.1 Node Inspector v0.12.8

Downgrading from 6.5.0 to 6.3.1 fixed it for me as well.

I can still reproduce it with v6.3.1 😦 on linux

~$ node-inspector --debug-port 5859 --no-preload
Node Inspector v0.12.8
Visit http://127.0.0.1:8080/?port=5859 to start debugging.
/home/egnyte/.nvm/versions/node/v6.3.1/lib/node_modules/node-inspector/lib/InjectorClient.js:111
      cb(error, NM[0].ref);
                     ^

TypeError: Cannot read property 'ref' of undefined
    at InjectorClient.<anonymous> (/home/egnyte/.nvm/versions/node/v6.3.1/lib/node_modules/node-inspector/lib/InjectorClient.js:111:22)
    at /home/egnyte/.nvm/versions/node/v6.3.1/lib/node_modules/node-inspector/lib/DebuggerClient.js:121:7
    at Object.create.processResponse.value (/home/egnyte/.nvm/versions/node/v6.3.1/lib/node_modules/node-inspector/lib/callback.js:23:20)
    at Debugger._processResponse (/home/egnyte/.nvm/versions/node/v6.3.1/lib/node_modules/node-inspector/lib/debugger.js:95:21)
    at Protocol.execute (_debugger.js:121:14)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at readableAddChunk (_stream_readable.js:177:18)
    at Socket.Readable.push (_stream_readable.js:135:10)
    at TCP.onread (net.js:542:20)
~$ node --version
v6.3.1

Why is this ticket closed? Still having this problem in node 6.9.2.

i have same problem ,node v6.6.0 and node inspector v0.12.8 and centos 7 wrote the code in the line 111 of

/usr/lib/node_modules/.node-inspector_npminstall/node_modules/.0.12.8@node-inspector/lib/InjectorClient.js

if(NM.length > 0)

it’s working!!!

my problem can also be solved like this :

Edit ...\node_modules\node-inspector\lib\InjectorClient.js file at line 111
if(NM.length > 0)
cb(error, NM[0].ref);

It works well!!!

It work in node v6.1.0 and Node Inspector v0.12.8,my OS is macos EI Caption(10.11).

Still b0rked on v6.10

@wujunchuan node --inspect app.js works well! Thanks!

node version 6.9.1 still broken me too

I have set up the debugging after @Pierre-LoanJ description or I just use node --inspect app.js. Everything looks good so far. I can debug the first start in the app.js. But if I want to debug an endpoint with POSTMAN, I get the error “Cannot POST /api/trainingsWeek”. The endpoint works if I don’t debug.

Do I have to take another address? Or anoter tool than POSTMAN?

first second third

@scniro

Sorry its been a while. I had trouble using the node-inspect module, so I updated node to use the built-in v8 debugger released in 6.3.0.

Using the v8 debugger, I then ran into an issue where the dev-tools were loading but no code was loading. This was because I had my hosts files mapping localhost to a different address than default. I changed this mapping and then --inspect or --inspect --debug-brk worked.

Further, it seems that there has been an update to node in 6.9.2 to resolve that problem I had with inspector by having inspector now prompt user to use 127.0.0.1 rather than localhost.

Downgrading to 6.3.1 worked for me

@wujunchuan worked for me, on node 6.9.1. great

xxx@xyz MINGW64 /c/nodejs/projects/todo-app

$ node --inspect index.js
Debugger listening on port 9229.
Warning: This is an experimental feature and could change at any time.
To start debugging, open the following URL in Chrome:
    chrome-devtools://devtools/remote/serve_file/@60cd6e859b9f557d2312f5bf532f6aec5f284980/inspector.html?experiments=true&v8only=true&ws=localhost:9229/b4f005c7-caad-4e7c-b554-5746da12b549
Server listening on 3000
Debugger attached.

node version 6.9.1 still broken

There is more to that in the thread?! 1). Use the --inspect flag of node. 2). Insert the patch.

Are people using some kind of alternative to this? is this project dead or obsolete? Did that BM.length patch work or not? It’s unclear without a proper PR submitted.

I have encountered the same bug. node v6.9.0 LTS node-inspector v0.12.8

The project dependencies include the below: “artikcloud-js”: “2.0.2”, “babel-polyfill”: “^6.13.0”, “body-parser”: “^1.13.1”, “body-parser-xml”: “^1.1.0”, “canvas”: “1.5.0”, “cheerio”: “^0.19.0”, “compression”: “^1.6.1”, “connect”: “^3.4.0”, “connect-busboy”: “0.0.2”, “connect-flash”: “^0.1.1”, “connect-multiparty”: “^1.2.5”, “connect-redis”: “^3.1.0”, “connect-static”: “^1.5.0”, “connect-timeout”: “^1.6.2”, “continuation-local-storage”: “^3.1.4”, “cookie-parser”: “^1.3.5”, “cookie-session”: “^1.2.0”, “cookies”: “^0.5.0”, “cors”: “^2.7.1”, “csurf”: “^1.8.3”, “dateformat”: “^1.0.11”, “ddos”: “^0.1.11”, “domain”: “0.0.1”, “ejs”: “^2.3.2”, “express”: “^4.13.0”, “express-partials”: “^0.3.0”, “express-session”: “^1.11.3”, “follow-redirects”: “0.0.7”, “http-framework”: “^1.2.0”, “js-throttle-debounce”: “^0.1.1”, “keygrip”: “^1.0.1”, “log4js”: “^0.6.26”, “method-override”: “^2.3.3”, “mojio-js”: “^3.5.2”, “mongodb”: “^2.1.0-alpha”, “mongoose”: “^4.1.1”, “msgpack-js”: “^0.3.0”, “multer”: “^0.1.8”, “mysql”: “^2.8.0”, “nconf”: “^0.8.2”, “nodemailer”: “^2.2.1”, “nodemailer-smtp-transport”: “^2.4.1”, “passport”: “^0.3.2”, “passport-local”: “^1.0.0”, “q”: “^1.4.1”, “qs”: “^4.0.0”, “query-types”: “^0.1.4”, “raw-body”: “^2.1.1”, “redis”: “^0.12.1”, “response-time”: “^2.3.1”, “sequelize”: “3.24.3”, “serve-favicon”: “^2.3.0”, “serve-index”: “^1.7.0”, “serve-static”: “^1.10.0”, “socket.io”: “1.5.0”, “socket.io-adapter”: “^0.4.0”, “socket.io-parser”: “^2.2.6”, “source-map-support”: “^0.4.0”, “st”: “^0.5.4”, “text-table”: “^0.2.0”, “uid2”: “0.0.3”, “umzug”: “^1.8.0”, “underscore”: “^1.8.3”, “vhost”: “^3.0.1”