I am trying to use node-inspector with a simple script. I have some console logs in place so I can tell if it's running or not. I have tried 2 ways:
node-debug test.js
With this approach, the debugger opens in chrome, but does not break and runs without giving me a chance to enter break points.
In terminal window #1:
~ $ node-inspector
Node Inspector v0.9.2
Visit http://127.0.0.1:8080/debug?port=5858 to start debugging.
Open debugger in chrome. In terminal window #2:
node --debug-brk test.js
The script seems to be waiting, but the debugger window I opened has nothing going on, So I refresh the page. As soon as I do, I see my console logs (not breaking).
I'm running OSX Yosemite (10.10.1), Node.js v0.12.0, NPM 2.5.1, and Node-inspector v0.9.2.
Any ideas why this is happening?
This is a known bug when running on Node v0.12 and io.js, see https://github.com/node-inspector/node-inspector/issues/534
Related
I faced a very strange problem. I have two working PC and one of them stop breaking on the breakpoints in one day. Another PC works properly the same as before.
I tried to reinstall Node JS, ts-node and then even hard reset for windows (I use Windows) but without any success.
Then I thought that probably issue in my project and I tried to clone hello world project from google tutorial and I found that I still can't debug with it!
So I successfully run an app on my port but breakpoint won't hit. This stop working in VS Code, in WebStorm and even Chrome debugger.
This is how I run an app: "C:\Program Files\nodejs\node.exe" --inspect --require ts-node/register C:\Projects\node-typescript-starter-master\src\index.ts
Then I opened dev tools from chrome and I see this:
Then I pressed "inspect" and I see message in console:
Debugger attached. Debugger listening on ws://127.0.0.1:9229/8bae9408-867c-4278-9148-b6c90b35a8ae For help, see: https://nodejs.org/en/docs/inspector Debugger attached.
This is the next window. Seems like I missing any files overhere.
Does this mean that something is wrong with my file mapping ?
Please, let me any suggestion what can be a problem.
Well, one of workaround is to don't use ts-node and just use default node js debugger config from WebStorm with adding TypeScript prelaunch compilation script.
Here is a screenshot how to configure:
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?
Not the answer specifically, but as of Node v6, you can actually just use the --inspect flag when you start a process, and it will let you use the Chrome debugging tools instead of relying on node-inspector. Check it out:
https://nodejs.org/docs/latest/api/debugger.html#debugger_v8_inspector_integration_for_node_js
Hope this helps!
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.
I had also faced this issue , but after lots of googling and finding about this issue. The only thing work for me is listed below :
Open your Command Promp(cmd) & type node -v, it will show you the version of node installed on your machine.
If the installed version is something 5.x.x or 6.x.x , then proceed further.
just uninstall this node version from control panel.
Install the node release with version 4 . I've tested with Node version v4.5.0 & I hope it will work fine for all Node with version v4.x.x.
Uninstall the previous node-inspector with command npm uninstall node-inspector -g.
Then Install again with command npm install node-inspector -g.
Then start debugging .. :)
I am currently having trouble getting node inspector to work with Google Chrome. I am on Windows 7 64 bit.
here is info about node-inspector:
https://github.com/node-inspector/node-inspector
when I run the following
node-debug app.js
on a simple JavaScript file called app.js:
a = 5;
b = 6;
c = a + b;
console.log(c);
and I open up Chrome with the following URL:
http://localhost:8080/debug?port=5858
all I get is this empty page with nothing loaded except one little part of the Chrome debugging toolbar, no matter what I do, I even reinstalled Chrome ( and the Canary developer version too):
Anyone have any idea what could be going wrong? This is the simplest JavaScript application ever, and there node-inspector directions does not specify any other steps to take. Like I said, I resinstalled Chrome. I have node version v0.10.30, npm version v1.4.21 version and node-inspector version: v0.7.4.
Does anyone have a good idea how I can test Chrome debugging tools without involving node? I am new to all this.
When I installed node-inspector, I did get what looks like a warning:
Try starting it without node-debug wrapper.
So, install node inspector:
npm install -g node-inspector
In one terminal:
node --debug-brk app.js
In a different terminal:
node-inspector
Browse to http://localhost:8080/debug?port=5858
i had the same issue. i then uninstalled node-inspector, installed it again. closed the cmd prompt which installed node-inspector (maybe this step made the difference). opened another cmd prompt to node-debug my.js. i can see the source file now.
I had a similar issue where going to http://localhost:8080/debug?port=5858 would result in an empty page. However going to http://127.0.0.1:8080/debug?port=5858 seems to do the trick.
I have written some test cases and I am trying to debug the test cases using using mocha and node debug.
I have mocha installed on my machine
I installed node-debug npm install -g node-debug
Then I am running test by this command: node-debug _mocha test.js
This opens a browser window, but I am getting following error
Detached from the target
Remote debugging has been terminated with reason: Error: connect ECONNREFUSED. Is node running with --debug port 5858?
Please re-attach to the new target.
See the attached image for more information:
How can I get rid of this error. Please help.
That is expected behavior once your tests have finished running. Put a long timeout in your test so it does not die and try it again.
You will also want to run mocha with a very high timeout so your tests don't die timing out.
The node-debug project is deprecated.
If using node > 6.3, The debugger is a part of the node core!
see https://medium.com/#paul_irish/debugging-node-js-nightlies-with-chrome-devtools-7c4a1b95ae27#.3qx9qfmwl
If using node < 6.3, you can use node-inspector
Check out https://github.com/node-inspector/node-inspector
The rest should be smooth sailing if your test is not ending the process before you're done debugging. You can also set --debug-brk so it stops on the first line of your code to give us slow humans a chance to get to the debuggeer.
Best of luck!
I know how to debug http applications using node-inspector and iisnode. But can I use node-inspector to debug a non http node application, on windows?
I tried:
node debug test.js
It says:
debugger listening on port 5858
But opening http://localhost:5858/ in Chrome does not do anything.
BTW: running node debug test.js does start the command-line debugger which works. But it's nothing like node-inspector.
To use node-inspector, the right switch is node --debug not node debug
Here are the detailed steps:
install node-inspector globally (npm install -g node-inspector)
from a command-line window, run: node-inspector
open Chrome and go to http://localhost:8080/debug?port=5858. You'll get the node-inspector UI but without any running app.
from another command-line window, run your app with the --debug switch like this: node --debug test.js
refresh the Chrome tab and voila!
A few interesting points:
If you kill your app and start it again, just refresh the node-inspector tab. It will keep all your breakpoints.
To break automatically on the first line start your app with node --debug-brk test.js
Some links which might help you:
http://vimeo.com/19465332 (screencast from Ryan himself).
https://github.com/joyent/node/wiki/using-eclipse-as-node-applications-debugger
It says: debugger listening on port 5858
I wondered myself about this but since the Node.js documentation indicates that the debugger is accessible via a simple TCP protocol and says nothing about HTTP my guess is that no, it won't be available at _http://localhost:5858.
"V8 comes with an extensive debugger which is accessible out-of-process via a simple TCP protocol" - http://nodejs.org/api/debugger.html
Very recently Microsoft released the node.js tools for Visual Studio. It has the very comfortable Visual Studio debugging for node.js.
node-inspector could be very helpful.
Use it from any browser supporting websockets.
Breakpoints, profiler, livecoding, etc..
http://erickrdch.com/2012/09/debug-a-nodejs-app-with-chrome-dev-tools.html
FYI, in OSX 10.8, Chrome v26 doesn't seem to work, but Safari 6 does using the same instructions as above and using 0.0.0.0:8080 to conect.
There is another post by Danny Coates somewhere that says to do it in the following order:
Your node process: node --debug (or --debug-brk) my_program.js
Node-inspector: node-inspector
The browser pointed to 0.0.0.0:8080
If you are a noob like me on Windows, and you get 'node-inspector not recognized' or something about windows JScript error... despite global install, adding to PATH, etc. then this may help.
Navigate to C:\Users\urusername\AppData\Roaming\npm
Then run node-debug.cmd or node-inspector.cmd
You should get magical words like
Node Inspector v0.12.7
Visit http://127.0.0.1:8080/?port=5858 to start debugging.
Debugger listening on port 5858
Awesome. If you know of a better solution, please let me know