question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

node-debug on windows doesn't work.

See original GitHub issue

It’s kind of unclear if node-debug script.js should work on windows. Is it supposed to work? In my case it does not work, I get this error:

C:\test>node-debug test.js
Node Inspector v0.12.8
Visit http://127.0.0.1:8080/?port=5858 to start debugging.
Debugging `test.js`

Debugger listening on [::]:5858
C:\Users\pps\AppData\Roaming\npm\node_modules\node-inspector\lib\InjectorClient.js:111
      cb(error, NM[0].ref);
                     ^

TypeError: Cannot read property 'ref' of undefined
    at InjectorClient.<anonymous> (C:\Users\pps\AppData\Roaming\npm\node_modules\node-inspector\lib\InjectorClient.js:111:22)
    at C:\Users\pps\AppData\Roaming\npm\node_modules\node-inspector\lib\DebuggerClient.js:121:7
    at Object.value (C:\Users\pps\AppData\Roaming\npm\node_modules\node-inspector\lib\callback.js:23:20)
    at Debugger._processResponse (C:\Users\pps\AppData\Roaming\npm\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:176:18)
    at Socket.Readable.push (_stream_readable.js:134:10)
    at TCP.onread (net.js:543:20)
events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: read ECONNRESET
    at exports._errnoException (util.js:1026:11)
    at TCP.onread (net.js:564:26)

C:\test>

while I get that error in console I get chrome-inspector started and I always get this error there.

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:1
  • Comments:8

github_iconTop GitHub Comments

3reactions
15920353089commented, Sep 27, 2016

just I see others:

Try this hack/workaround Seek in /usr/lib64/node_modules/node-inspector/lib/InjectorClient.js (your location of node-inspector) Look at Function InjectorClient.prototype._getFuncWithNMInScope

Replace this

cb(null, result.handle); with this

cb(null, result.constructorFunction.ref); I have this message in node-ispector console tab

Internal error: TypeError: Cannot read property ‘0’ of undefined But breakpoints and other stuff works. Tested with 6.6.0

P.s. Seems node-inspector method for retrieval NativeModule link fails to handle -1 even with #906 or similar because this solves problem with response, but not with request. You will recieve this message

Error: No NativeModule in target scope and you will not able to go through breakpoints with node-inspector’s UI.

2reactions
ameloncommented, Sep 13, 2016

The problem is here: https://github.com/node-inspector/node-inspector/blob/master/lib/InjectorClient.js#L98-L113

InjectorClient.prototype._findNMInScope = function(funcHandle, cb) {
    this._debuggerClient.request('scope', {
      functionHandle: funcHandle
    }, function(error, result, refs) {
      if (error) return cb(error);

      var NM = refs[result.object.ref].properties.filter(function(prop) {
        return prop.name == 'NativeModule';
      });

      if (!NM.length)
        error = new Error('No NativeModule in target scope');

      cb(error, NM[0].ref);
    }.bind(this));
};

Test if (!NM.length) should call cb and return

InjectorClient.prototype._findNMInScope = function(funcHandle, cb) {
    this._debuggerClient.request('scope', {
      functionHandle: funcHandle
    }, function(error, result, refs) {
      if (error) return cb(error);

      var NM = refs[result.object.ref].properties.filter(function(prop) {
        return prop.name == 'NativeModule';
      });

      if (!NM.length)
        return cb(new Error('No NativeModule in target scope'));

      cb(error, NM[0].ref);
    }.bind(this));
};
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use Node's debug module (Windows)? - Stack Overflow
Install debug package with npm inside the node application npm install debug. Open a powershell and then
Read more >
Debugger does not work when running Node.js on ... - GitHub
I am using the portable builds of node and vscode, but had no issues with them before. Only the debugging never worked. Every...
Read more >
Debug Node.js Apps using Visual Studio Code
The Visual Studio Code editor includes Node.js debugging support. Set breakpoints, step-in, inspect variables and more.
Read more >
NodeJS 17 debugger doesn't work on Windows with IPv6
NodeJS 17 debugger doesn't work on Windows with IPv6 · Set environment variable JB_IDE_HOST=127.0.0.1 · Configure Windows to prefer IPv4 over IPv6 ·...
Read more >
Set up Node.js on WSL 2 - Windows - Microsoft Learn
Windows doesn't automatically handle this update. ... versions of Node.js based on the needs of different projects you're working on.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found