node-inspector: Throwing exception on simple use case
First time using node-inspector. Here’s my setup:
$ nvm --version
0.31.4
$ nvm current
v6.4.0
$ node --version
v6.4.0
$ npm install -g node-inspector
My simple test file:
//test.js
var d = {asdf: 123}
debugger;
console.log(d)
Firing up the debugger throws exception:
$ 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
/Users/wes/.nvm/versions/node/v6.4.0/lib/node_modules/node-inspector/lib/InjectorClient.js:111
cb(error, NM[0].ref);
^
TypeError: Cannot read property 'ref' of undefined
at InjectorClient.<anonymous> (/Users/wes/.nvm/versions/node/v6.4.0/lib/node_modules/node-inspector/lib/InjectorClient.js:111:22)
at /Users/wes/.nvm/versions/node/v6.4.0/lib/node_modules/node-inspector/lib/DebuggerClient.js:121:7
at Object.create.processResponse.value (/Users/wes/.nvm/versions/node/v6.4.0/lib/node_modules/node-inspector/lib/callback.js:23:20)
at Debugger._processResponse (/Users/wes/.nvm/versions/node/v6.4.0/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)
About this issue
- Original URL
- State: open
- Created 8 years ago
- Reactions: 88
- Comments: 62 (1 by maintainers)
Commits related to this issue
- Fix #905 exception — committed to lynx1983/node-inspector by lynx1983 8 years ago
- Fix #905 exception — committed to ELLIOTTCABLE/node-inspector by lynx1983 8 years ago
- workaround for bug 905 https://github.com/node-inspector/node-inspector/issues/905 — committed to dewdad/node-inspector by dewdad 8 years ago
- Stop using node-inspector, which is broken for recents node versions. https://github.com/node-inspector/node-inspector/issues/905 This is a real drag, because the node debugger lacks simple affordan... — committed to mozilla/fathom by erikrose 8 years ago
- Added this fix as suggested in #905 Link: https://github.com/node-inspector/node-inspector/issues/905 — committed to AndreSteenveld/node-inspector by AndreSteenveld 8 years ago
- Fix error caused by https://github.com/node-inspector/node-inspector/issues/905 — committed to gcoombe/node-inspector by gcoombe 8 years ago
@wzup solution: stop using windows.
Those running 6.5.0 can use native node for the same purposes. It’s an experimental feature, but it works fine for me.
node --inspect --debug-brk my-app.js
.Read more here.
Not necessarily a good long term fix, but I worked around the problem with the following change to
node-inspector/lib/InjectorClient.js
:The debugger loads successfully and I am able to debug my code.
Same problem in 6.5.0
For anyone using homebrew and trying to get back to node 6.3.1 after you’ve already done a cleanup you can re-install 6.3.1 with:
and then switch with:
node-inspector is the most popular debug tool for Node. Based on statistic, more than 10k downloads in the last day. This open critical issue prevents using node v6.5.0 for developers. I really appreciate Your debug framework and all effort by node-inspector developers but more than 29 days delay to provide solution is not fair. I’m sorry!
I landed here after spending several hours trying to make things working.
Windows 7, Node 6.4.0 - x64 version.
When, after running node-inspector (or node-debug, or node --debug-brk, etc) I tried to go to the given address (with the GUI debugger with those devtools), the node proccess (and node-inspector proccess, if it was run separately) was crashing. No matter what I tried to do to solve it (downgrading node-inspector included).
In the cmd, the stack trace wasn’t really helpful (some exceptions from events.js and something about TCP, sorry, didn’t save them). I think they were the same as in javfindly’s post.
From the browser, I could only learn that it had something to do with closed websocket and the inspector didn’t worked at all (it was empty and console didn’t work as well).
After using lynx1983’s fix, I also noticed:
“No NativeModule in target scope.”
After all, I downgraded Node to 6.3.1 and it’s working.
Instead of commenting out. Fixed the issue with using:
cb(error, NM[0] && NM[0].ref);
I’ve done a PR too but apparently nobody is maintaining this repo.
On Wednesday, 19 October 2016, Master James notifications@github.com wrote:
Comment out line 111, it works!
@LeandroFavero The problem is that hype on Node.js is over, and a lot of temporary solutions became permanent due to the lack of professional developers. Unfortunately
--inspect
is unstable and doesn’t work for most of the interested users. I would expectnode-inspector
to disappear the same time asnode-gyp
would get Unicode support and drop Python from dependencies.For the future commenters: consider using emoji reactions if you have the same setup as previous reporters. There’re 2 messages a day with the same content, and it’s annoying.
👍
Downgrade to 6.3.1 helps. This is a regression,
same issue here, in my case happens when I run Jest:
node-debug node_modules/jest-cli/bin/jest.js -i
Node Inspector v0.12.8 Visit http://127.0.0.1:8080/?port=5858 to start debugging. Debugging
node_modules/jest-cli/bin/jest.js
Debugger listening on [::]:5858
/usr/local/lib/node_modules/node-inspector/lib/InjectorClient.js:112 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:112:22) at /usr/local/lib/node_modules/node-inspector/lib/DebuggerClient.js:121:7
I’ve already checked, the NM object is an empty array
node: v6.9.1 osx: 10.12.2 sierra
It works for me 💯 . I know this is not a right fix but works temporarily 😃
Also - add the “–debug-brk” option to “–inspect” and the debugger will pause execution until after you connect:
node --inspect --debug-brk your.js
You can then start execution from inside the debugger (after setting any necessary breakpoints).
Same here Windows x64 Node : 6.6.0
Downgrade is not a solution for me! Hope it’s gone be fixed soon…
Same issue here:
Node version: v6.5.0 Npm version: 3.10.6 Node Inspector v0.12.8
cb(error, NM[0].ref); ^ TypeError: Cannot read property ‘ref’ of undefined
@kmkr
No they can’t.
node --inspect
doesn’t work on Windows 64 yetSmall addition to the above code - I had to unlink node first, then I could install and switch to 6.3.1.
brew unlink node
Broken here too. Node 6.7.0 + MacOS Sierra.
Debugger listening on [::]:5858 /usr/local/lib/node_modules/node-inspector/lib/InjectorClient.js:111 cb(error, NM[0].ref); ^
TypeError: Cannot read property ‘ref’ of undefined
same problem here with:
i run node via nvm, with version 4x and 5x its working:
but crashes on current 6x with
Same problem with Node 6.5.0 on OSX El Capitan (Ver 10.11.6). Downgrading to 6.3.1 did not solve the problem!!
Same problem
I don’t understand why or how downgrading node version could solve the issue because this code is clearly bugged.
Of course if
NM.length
is0
any access to its inexistent indexes properties likeNM[0].ref
would fail.Accordingly, before even thinking about a possible PR, what should actually happen when
NativeModule
is not found? A warning? Another attempt? Would passing theerror
and justnull
, instead of throwing an error, be appropriate?@fignuts but what version of node.js are you using?
im using windows 10 with node 6.6(before) …
to solve this I uninstalled node and downloaded node 4.5 from the official nodejs site
hope this helps someone
The lastest release was in April 8. I don’t know the future about node-inspector, but I believe that will die. Because NodeJS incorporated the inspector. Try this using 6.6.0: node --inspect index.js
It’s the same, but integrated and faster, really faster!!!
I’ve the same issue, exception are thrown when connecting browser to :8080 port.
I think problem is related to node version, all works with node@6.3.1 and start failing when updated to node@6.4.0
All start working again after rolling back node to 6.3.1